joebudden Posted January 7, 2007 Share Posted January 7, 2007 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 appreciatedcheers Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/ Share on other sites More sharing options...
.josh Posted January 7, 2007 Share Posted January 7, 2007 -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. Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155139 Share on other sites More sharing options...
scott212 Posted January 7, 2007 Share Posted January 7, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155156 Share on other sites More sharing options...
joebudden Posted January 7, 2007 Author Share Posted January 7, 2007 well its an application for employees to log in and upload files to a database.probably a pointless feature just thought if it was simple i cud incorporate it, i probably wont bother if its gonna be complicatedcheers anyway guys Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155226 Share on other sites More sharing options...
magic2goodil Posted January 7, 2007 Share Posted January 7, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155247 Share on other sites More sharing options...
scott212 Posted January 7, 2007 Share Posted January 7, 2007 That's what crayon mentioned earlier, but how would [i]you [/i]address the logged out status? Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155256 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 [quote]That's what crayon mentioned earlier, but how would you address the logged out status?[/quote]You'll also need a timestamp field. Whenver a page is called, update the current users timestamp. Then, you'll need to run another query deleting older timestamps. Quote Link to comment https://forums.phpfreaks.com/topic/33230-displaying-other-users-logged-in/#findComment-155262 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.