PHP loggout
Moderator: General Moderators
PHP loggout
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?
-
mattpointblank
- Forum Contributor
- Posts: 304
- Joined: Tue Dec 23, 2008 6:29 am
Re: PHP loggout
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.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: PHP loggout
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