View Full Version : Destroying session on browser tab close

08-25-2009, 04:58 PM
I understand that session data is only destroyed when the user completely exits the browser. However, the data remains intact if the user only exits out of the tab in the browser. Is there any piece of code which would destroy a session when exiting a tab? I tried Googling this, but I couldn't find anything.


08-25-2009, 05:54 PM
You may be able to implement a javascript method to handle it, but I don't know if there is an ontabclose or anything like that. I haven't used JS since before tabbed browsing.
So long as the browser is running, it will not delete session based (temporary) cookies.

08-25-2009, 06:44 PM
What is the purpose of this? It may be possible to accomplish what you want indirectly, for instance by keeping a timer since last page load or something and destroying the session if the timer passes a certain time.


08-25-2009, 10:24 PM
Even if you were to implement some sort of JavaScript solution, you could never actually depend on it working. Browsers crash, some people don't have JavaScript enabled, the browser is left open and the session times out, etc. Basically you just don't know for sure, so you just have to wait for their session to expire on the server.