web2000 Posted May 20, 2007 Share Posted May 20, 2007 Hi, I am trying to delete a session when the page is left. So basically when the page is unloaded, either shut down or if the browser has gone to another page it will delete the session. Any help would be much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/52244-sessions/ Share on other sites More sharing options...
trq Posted May 20, 2007 Share Posted May 20, 2007 Pretty difficult to do reliably. You'd need to open a popup (on page unload) which would kill the session. There may be some Ajax trickery you could try also, but yeah... most solutions are going to be pretty unreliable. Quote Link to comment https://forums.phpfreaks.com/topic/52244-sessions/#findComment-257752 Share on other sites More sharing options...
chocopi Posted May 20, 2007 Share Posted May 20, 2007 I dont know that much but couldnt you just timestamps etc to do it, so when the user logs out or the time is up the session is destroyed etc Quote Link to comment https://forums.phpfreaks.com/topic/52244-sessions/#findComment-257756 Share on other sites More sharing options...
web2000 Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks for the advice guys, how can i actually just delete a session? Is there a way or do i have to set a timeout on the sesssion before it will go away? Quote Link to comment https://forums.phpfreaks.com/topic/52244-sessions/#findComment-257760 Share on other sites More sharing options...
trq Posted May 20, 2007 Share Posted May 20, 2007 This will clear the $_SESSION array. <?php session_start(); $_SESSION = array(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/52244-sessions/#findComment-257764 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.