conker87 Posted February 29, 2008 Share Posted February 29, 2008 I've got a pretty simple yet effective login script, works great. Now I'm wanting to take it a little further and show when the user(s) in online on the member list. I know I can do this through sql, adding an `online` field to the db, but the only problem is if the user doesn't click the 'logout' link and the session expires then the db will not be updated (and so the user will be shown as still logged in even though said session is no more). Anyone got any ideas on how I could actually make this work? Ta. Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/ Share on other sites More sharing options...
trq Posted February 29, 2008 Share Posted February 29, 2008 You need to run a cron job which deletes users who have been inactive for a set amount of time. Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/#findComment-479911 Share on other sites More sharing options...
conker87 Posted February 29, 2008 Author Share Posted February 29, 2008 Hmm, I'm not looking at removing people who hasn't been online in a set amount of time. I'm looking for something that will give a visual notice (IE, "<user> Is online!") in the members list and when they logout this notice is removed. Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/#findComment-479913 Share on other sites More sharing options...
mmarif4u Posted February 29, 2008 Share Posted February 29, 2008 Thorpe is not talking about to delete users from db. He mean,make separate table in db and store sessions related data there. Then run cron job at a specific amount of time.Then delete the data after some time. Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/#findComment-479915 Share on other sites More sharing options...
conker87 Posted February 29, 2008 Author Share Posted February 29, 2008 Ahha. I shall have to have a look whether the host does cron jobs, if it does I shall look into it. ) Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/#findComment-479917 Share on other sites More sharing options...
moon 111 Posted February 29, 2008 Share Posted February 29, 2008 Since the only time it will be seen is when a user views the page that shows it, you can update the list when someone views the page. Basicly have two fields online and last_seen. Online is a boolean reffering to if he is online or not and last_seen is the "time()" value of when he was last seen. Then when someone views the page you can go through the list and delete those that haven't been seen in a set period of time (delete as in set online to 0). A cron job however would be much less CPU intensive. Link to comment https://forums.phpfreaks.com/topic/93671-login-script-is-online/#findComment-479918 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.