I have an application that uses sessions. If the users keep the browser open and do nothing, the session dies after 24mints. (The default time out in php.ini). If they click logout, the session gets destroyed. However, if they click on the [x] of the browser, the session stays alive, it does not get destroyed. How can I tell the server that if the user clicked on the [x] and closed the browser, it has to destroy the session?
I read a lot on ajax solutions with javascript and there is no window.onclose() that will help. The onunload() function does not do what I need. I understand that php is a server side script and javascript is a client side; but, is there any “trick” in php that can detect if the user clicks on the [x] on the browser? and if so, destroy/unset the session? Any advice would be highly appreciate it. I just need to keep track of when the user start and end the session.