Page 1 of 1
PHP session
Posted: Fri Apr 27, 2007 4:23 am
by babajee
when session_destory is executed the user logged out, but if direct window is closed then session _destroy is not excuted.
How can i executre at direct browser closed event.
Posted: Fri Apr 27, 2007 4:33 am
by onion2k
Closing the browser window doesn't pass a request to the server, so you can't. You may be able to attach an AJAX request to the window.close() event I suppose .. assuming browsers allow a request to be sent after the user has tried to close their browser. Even if they did it wouldn't be very reliable because it'd rely on client side scripting.
You should really need to do this anyway. When a browser is closed down the session cookie is destroyed, so the session id is lost forever (assuming your session expiry time is 0). There shouldn't be any way for another user to carry on with the session by restarting the browser.
Posted: Fri Apr 27, 2007 9:46 am
by guitarlvr
with tabbed browsing, I've noticed that if you close the tab the website is in, it doesn't destroy the session. It sits out there until you close the browser and reopen it. Is there a way to destroy the cookie upon closing of the tab?
Wayne
Posted: Fri Apr 27, 2007 10:54 am
by onion2k
No. Sessions are stored for the duration of the browser session. Again, you might be able to attach an AJAX request (or even just a JS function to kill the cookie) to the window.close() event, which should be called when a user closes a tab, but I haven't tried so I don't know for certain.