kiwinz wrote:I've been playing about with php sessions (with no cookies)
kiwinz wrote:<?php session_start(); echo session_id(); ?>
creates and displays my session key in xampp/tmp and
kiwinz wrote:<?php session_destroy(); ?>
deletes the key.
session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.
In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that.
kiwinz wrote:(2)Also, if - instead of session_destroy() - I just close my browser, the session key in xampp/tmp isn't deleted at all. That doesn't look right to me - shouldn't the key be destroyed whenever the browser is closed, irrespective of whether a session_destroy has been processed or not ...?
kiwinz wrote:I could be wrong here, but It seems like garbage collection probability must be calculated to 1 (= certainty) to successfully purge session keys ...
kiwinz wrote:'No cookies' just means I'm not using client-side session management, it's all being done on the server.
kiwinz wrote:But from what I've read at http://stackoverflow.com/questions/7587 ... hp-session it looks like an open session key existing after a session_destroy() isn't an issue, as the session array will be emptied anyway, so the key could be safely re-used.
kiwinz wrote:I suppose it could be overwritten with session_regenerate_id() immediately after session_destroy(), but that wouldn't work if the user just closes their browser without signing off, as session_destoy() wouldn't be run in that case.
kiwinz wrote:Still, it looks like your suggestion of unset session_id() would be useful for reducing garbage in cases where the visitor does log off, and I'll just have to rely on time-out functions to clean up otherwise.
Users browsing this forum: No registered users and 66 guests