Jump to content

Online/Offline status


plutomed

Recommended Posts

I have been thinking about this for a while now. What is the best way to see if someone is online? For example in Facebook chat people log on and off all the time and if no response after a while you get the "busy". I am creating an online games system and want to play with other computers. If someone goes inactive after say 30s I want to be able to detect this. The best way I have come up with is to ping a script every 30s to say the person is still online and if the person hasn't pinged in they are set to offline.

 

Is this the best way or does anyone have any better ideas?

Link to comment
https://forums.phpfreaks.com/topic/203987-onlineoffline-status/
Share on other sites

You can set up a table in your database that contains the user ID, and their last activity. Every time they load a page, you update this table with their last activity. When you want to check if they are online or not, you query this table to get the time of their last activity, and if it's been more than ___minutes (choose whatever time you think is appropriate), then they are offline, and if it's been less than that, they are online.

you query this table to get the time of their last activity, and if it's been more than ___minutes (choose whatever time you think is appropriate), then they are offline, and if it's been less than that, they are online.

 

The same applies for setting them to busy.

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.