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.
PHP session
Moderator: General Moderators
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.
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.