Forum Moderators: coopster

Message Too Old, No Replies

loggin users off when they close the browser

         

distorto

6:44 pm on Oct 8, 2007 (gmt 0)

10+ Year Member



I have a site that tells you if users are "online now". I have a mysql collumn that is updated to "online" when a user logs into the system.
My problem is that unless the user specifically logs off the system (by clicking a log off button), they stay logged in forever.
How do I change their status to "not online" if they have closed the browser or have not interacted with the site for an extended period of time?

PHP_Chimp

7:14 pm on Oct 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You would need to use a client side script to tell you when they close the browser or if there is an error and the browser disconnects. Javascript onerror and onunload would do it.

For a php solution you would need to use something like another column in your table that has the timestamp when the user last sent anything. You could then check that people have submitted info within the last 5 mins (or whatever time you want) and if they havent then have them shown as logged off.