onedumbcoder Posted April 3, 2009 Share Posted April 3, 2009 I am trying to figure out a way to determine if a user is online or not. How would I go about doing that? I want it so that when they leave the site, close the window it recognizes the action and changes their status. Is this even possible? Link to comment https://forums.phpfreaks.com/topic/152419-is-there-a-way-to-tell-the-user-left/ Share on other sites More sharing options...
Yesideez Posted April 3, 2009 Share Posted April 3, 2009 A table "onlineusers". Someone logs in an entry is created with their user ID and time. Every time they visit a page that time is reset in the table. If no activity for, let's say 20 minutes, another script running (cron job is best) every minute or so clearing out those with expired times. If the user is active again their entry is re-created in the table with a new time. Link to comment https://forums.phpfreaks.com/topic/152419-is-there-a-way-to-tell-the-user-left/#findComment-800460 Share on other sites More sharing options...
onedumbcoder Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks but what I am looking for is to be able to execute a script upon leaving the site or closing the window which would be more accurate. Link to comment https://forums.phpfreaks.com/topic/152419-is-there-a-way-to-tell-the-user-left/#findComment-800466 Share on other sites More sharing options...
Yesideez Posted April 3, 2009 Share Posted April 3, 2009 Javascript! I wouldn't rely on it though because if someone doesn't have Javascript enabled (and many don't!!!) people will never be logged out. onclose() Link to comment https://forums.phpfreaks.com/topic/152419-is-there-a-way-to-tell-the-user-left/#findComment-800473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.