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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.