Jump to content

displaying other users logged in


joebudden

Recommended Posts

Hi guys, iv written an application where user's can login.

Just wanted to know if there was any way of displaying to the user...

"There are 2 people logged in" - if two people are logged in and so on...

Would this be really complicated to achieve ???

any help would be muchly appreciated

cheers

Link to comment
https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/
Share on other sites

-create a field in your table called lastActive with a timestamp datatype.
-When user logs in, update lastActive.
-On each page load, update lastActive.
-In your "user's online" script, select * where lastActive < 1 minute or 5 minutes or 10 minutes or whatever how long you wish.

This is not really 100% accurate though.  Someone could spend an hour reading a thread and they'd technically be online, but according to the script, they won't be.  There's really no way around that.
I would like to expand on the original question if I may.

Would there be any reliable way to change the logged in status when the users session ended? Or if not that, maybe when a user is logged in, you could store there session id in the db and on a page reload, a search could get that list, then check that against list to see if the server still has any of these session open? Then you could see exactly who is online at any given time.

Is this possible?
a very simple way would be when the user logs in have a field called loggedin in the db..if it is set to 1, they are logged in...so in theory when a user is on a page..you can go through your members db and add those 1's and get a total of users logged in as well as sift through to get who exactly is logged in..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.