DrTrans Posted September 4, 2009 Share Posted September 4, 2009 for everyone who is logged in. ive got it setup if ($loggedin == "1") { $dbusername = $_SESSION['username']; } How do i make it show me every username who is logged in. Thanks Link to comment https://forums.phpfreaks.com/topic/173056-users-logged-in-based-on-session/ Share on other sites More sharing options...
rallokkcaz Posted September 4, 2009 Share Posted September 4, 2009 You'd have too make it so in the database there's a field that indicates if the user is online or not. It would be like: online = true when they sign in, and online = false when they sign out or the session expires. That's the only way todo it because sessions are local. Well there are other ways, but this is the most practical. -Zack Link to comment https://forums.phpfreaks.com/topic/173056-users-logged-in-based-on-session/#findComment-912192 Share on other sites More sharing options...
bundyxc Posted September 4, 2009 Share Posted September 4, 2009 How would you know when their session expires (if they close out of your site)? Obviously you can run a query in the event of a login/logout, but how would you know if they are logged in based on if they exit out of your site? I'm thinking you can just perform scheduled queries, saying "If the user hasn't visited a new page in the past hour, mark them as offline" or something... is that the way to go? Link to comment https://forums.phpfreaks.com/topic/173056-users-logged-in-based-on-session/#findComment-912206 Share on other sites More sharing options...
trq Posted September 4, 2009 Share Posted September 4, 2009 I'm thinking you can just perform scheduled queries, saying "If the user hasn't visited a new page in the past hour, mark them as offline" or something... is that the way to go? Thats pretty much how its done. You update a timestamp on each request, and also execute another query the deletes any user with a timestamp older than say 10 minutes. Link to comment https://forums.phpfreaks.com/topic/173056-users-logged-in-based-on-session/#findComment-912208 Share on other sites More sharing options...
bundyxc Posted September 4, 2009 Share Posted September 4, 2009 Oh I see. That way you don't need to use cron jobs or anything stupid.. right on thorpe. Link to comment https://forums.phpfreaks.com/topic/173056-users-logged-in-based-on-session/#findComment-912210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.