Page 1 of 1
PHP loggout
Posted: Thu Mar 26, 2009 11:23 am
by Spears
In the game I'm writing, I have a logout.php file that logs the user out. My problem is if someone closes out of the game without clicking the logout file, it tends to mess things up. Is there a good way to make it where clicking the X logs someone out?
Re: PHP loggout
Posted: Thu Mar 26, 2009 11:57 am
by mattpointblank
You can't track whether the user closes the window or not using PHP, but you could use session variables to track user activity - if they don't do anything for (say) 10 minutes, assume they closed the window and run the logout code automatically for them.
Re: PHP loggout
Posted: Thu Mar 26, 2009 12:22 pm
by Mark Baker
or you can always look at using onBeforeUnload/onUnload in javascript to send a logout request to the server, but these can also be triggered when moving from one page to another, or when hitting refresh in the browser