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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.