sleipnir214
Programmer
Tek-Tips user martinca sent me this question in an email sent through the site's "Send a comment about this FAQ" feature. This comment was in response to my FAQ, "Using MySQL to store PHP session variables".
Since I do not respond to email from people I don't know (no offense, martinca), I will repeat the question here and provide my answer.
The question, verbatim:
hi I would like to know how I can destory sesssion id form my /tmp directory and alos when someone closes the browser the session id should die please advice thanks
martinca:
A session consists of two parts: a session store on the server and a cookie on the browser.
The cookie is set with no expiration, which means whenever the web browser is shut down, it deletes all session cookies it knows about.
Removal of PHP session stores (whether on the server filesystem or in a database) are handled by PHP's session garbage collection system. There is a random chance (set as a percent in the runtime configuration directive "session.gc_probability"
that the garbage collection mechanism will operate every time a session is started. If you set this value to 100, garbage collection will run every time a session starts.
The runtime configuration directive "session.gc_maxlifetime" tells PHP in seconds how long a session store must have existed before the gargage collection mechanism removes it.
If the session cookie is deleted by the browser's shutdown, the session no longer works, even if the session store still exists on the filesystem.
If the session store is deleted, the session no longer works, even if the cookie still exists on the client. Want the best answers? Ask the best questions: TANSTAAFL!
Since I do not respond to email from people I don't know (no offense, martinca), I will repeat the question here and provide my answer.
The question, verbatim:
hi I would like to know how I can destory sesssion id form my /tmp directory and alos when someone closes the browser the session id should die please advice thanks
martinca:
A session consists of two parts: a session store on the server and a cookie on the browser.
The cookie is set with no expiration, which means whenever the web browser is shut down, it deletes all session cookies it knows about.
Removal of PHP session stores (whether on the server filesystem or in a database) are handled by PHP's session garbage collection system. There is a random chance (set as a percent in the runtime configuration directive "session.gc_probability"
The runtime configuration directive "session.gc_maxlifetime" tells PHP in seconds how long a session store must have existed before the gargage collection mechanism removes it.
If the session cookie is deleted by the browser's shutdown, the session no longer works, even if the session store still exists on the filesystem.
If the session store is deleted, the session no longer works, even if the cookie still exists on the client. Want the best answers? Ask the best questions: TANSTAAFL!