Jump to content

Login Script: "Is Online"


conker87

Recommended Posts

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

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.

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.