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
https://forums.phpfreaks.com/topic/157466-how-to-unset-a-session-onunload/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.