Page 1 of 1

Timer??

Posted: Mon Nov 15, 2010 9:40 am
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 :)

Re: Timer??

Posted: Mon Nov 15, 2010 12:05 pm
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)