legohead6 Posted May 31, 2006 Share Posted May 31, 2006 how do i find all the current sessions to make a thing to show whos logged in? or is that done some other way?ThanksMAtt Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/ Share on other sites More sharing options...
witt Posted May 31, 2006 Share Posted May 31, 2006 [!--quoteo(post=378562:date=May 30 2006, 08:55 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 30 2006, 08:55 PM) [snapback]378562[/snapback][/div][div class=\'quotemain\'][!--quotec--]how do i find all the current sessions to make a thing to show whos logged in? or is that done some other way?ThanksMAtt[/quote]Make an online column in the users table that will show 1 when logged in and 0 when not. Run a query like so:SELECT user_id FROM users WHERE online=trueto see who's online. Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/#findComment-40420 Share on other sites More sharing options...
legohead6 Posted May 31, 2006 Author Share Posted May 31, 2006 [!--quoteo(post=378564:date=May 30 2006, 09:06 PM:name=witt)--][div class=\'quotetop\']QUOTE(witt @ May 30 2006, 09:06 PM) [snapback]378564[/snapback][/div][div class=\'quotemain\'][!--quotec--]Make an online column in the users table that will show 1 when logged in and 0 when not. Run a query like so:SELECT user_id FROM users WHERE online=trueto see who's online.[/quote]o.. but how do i make it remove it if they exit? like clse the browser? Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/#findComment-40422 Share on other sites More sharing options...
trq Posted May 31, 2006 Share Posted May 31, 2006 You need to also make a timestamp, and on each request this needs to be updated. Then, as it updates, it should aslo check for old timestamps (sessions are by default set to expire after 20 mins) and remove these entries.There are better more complex ways of doing it, but that is the rough idea. Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/#findComment-40440 Share on other sites More sharing options...
legohead6 Posted May 31, 2006 Author Share Posted May 31, 2006 [!--quoteo(post=378584:date=May 30 2006, 10:59 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 30 2006, 10:59 PM) [snapback]378584[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to also make a timestamp, and on each request this needs to be updated. Then, as it updates, it should aslo check for old timestamps (sessions are by default set to expire after 20 mins) and remove these entries.There are better more complex ways of doing it, but that is the rough idea.[/quote]i have never used timestamps before....umm....can you show me how? Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/#findComment-40442 Share on other sites More sharing options...
trq Posted May 31, 2006 Share Posted May 31, 2006 The easiest way is just to use the now() Mysql function. eg;[code]$sql = "INSERT INTO active (id,stamp) VALUES ('$userid','NOW()');";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10813-finding-all-current-sessions/#findComment-40458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.