Timer??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ewannnn
Forum Newbie
Posts: 13
Joined: Thu Nov 04, 2010 9:46 am

Timer??

Post by ewannnn »

Hi I am working on a chat application and am a bit stuck...In the database I have a field status which is set 1 for online and 0 for offline (PHP/MySQL)(at time of logging in/out), this shows the users status on a webpage. What I need is to know if there is a way I can set a timer so that if the user has been inactive for X amount of time, the database is auto updated and user is offline (1 set to 0).
Thanks for any help I recieve :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Timer??

Post by Christopher »

Perhaps instead of 0|1 for your status, you should save the timestamp of the last user update. Then you could just check the time of the last update.

Otherwise you would need to do a timer in the client, or have a cron run on the server that cleared the status flags (you would still need a time though)
(#10850)
Post Reply