Jump to content

how to unset a session onunload??


garethhall

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.