Jump to content


Photo

finding all current sessions?


  • Please log in to reply
5 replies to this topic

#1 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 31 May 2006 - 01:55 AM

how do i find all the current sessions to make a thing to show whos logged in? or is that done some other way?

Thanks
MAtt
"Syntax error" .. WHERE THE **** IS IT?!

#2 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 31 May 2006 - 02:06 AM

[!--quoteo(post=378562:date=May 30 2006, 08:55 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 30 2006, 08:55 PM) View Post[/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?

Thanks
MAtt
[/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=true

to see who's online.

#3 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 31 May 2006 - 02:18 AM

[!--quoteo(post=378564:date=May 30 2006, 09:06 PM:name=witt)--][div class=\'quotetop\']QUOTE(witt @ May 30 2006, 09:06 PM) View Post[/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=true

to see who's online.
[/quote]

o.. but how do i make it remove it if they exit? like clse the browser?

"Syntax error" .. WHERE THE **** IS IT?!

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 31 May 2006 - 03:59 AM

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.

#5 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 31 May 2006 - 04:14 AM

[!--quoteo(post=378584:date=May 30 2006, 10:59 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 30 2006, 10:59 PM) View Post[/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?
"Syntax error" .. WHERE THE **** IS IT?!

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 31 May 2006 - 05:53 AM

The easiest way is just to use the now() Mysql function. eg;
$sql = "INSERT INTO active (id,stamp) VALUES ('$userid','NOW()');";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users