garethhall Posted May 9, 2009 Share Posted May 9, 2009 Hi guys I have a CMS that I am developing and admins login to administer the website. But when you close the browser I want it to unset the session. How can I do that? I know there is a javascript onunload function but that does not help as it client side or does it? My php session is pretty simple it just <? session_start(); $_SESSION['usersEmail'] = $usersEmail; ?> And then I just check on the subsequent pages that the session has been set. Link to comment https://forums.phpfreaks.com/topic/157466-how-to-unset-a-session-onunload/ Share on other sites More sharing options...
Renlok Posted May 9, 2009 Share Posted May 9, 2009 the javascript onunload is called every time you move to a different page and the sessions only last until you close the browser. Link to comment https://forums.phpfreaks.com/topic/157466-how-to-unset-a-session-onunload/#findComment-830196 Share on other sites More sharing options...
GingerRobot Posted May 9, 2009 Share Posted May 9, 2009 You'd be better off ensuring they've not been inactive for a while anyway. That way there's not an issue if they leave their browser open and are away from their computer for a while either. You can do this by storing a timestamp of their last activity and ,on each page load, checking to see it wasn't more than x minutes ago. If it was, log them out. Link to comment https://forums.phpfreaks.com/topic/157466-how-to-unset-a-session-onunload/#findComment-830231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.