Page 1 of 1

Online Indicator php code?

Posted: Sat Apr 14, 2007 12:21 pm
by chaser7016
Can anyone point me to such code, that shows status of user, whether they are online. Like on Myspace, it states user is online now and when not nothing is shown.

Thanks, Chaser

Posted: Sat Apr 14, 2007 12:24 pm
by John Cartwright
Everytime a user has a page request, update his `lastrequest` row in your users table (assuming its a timestamp). Then simply query with WHERE `lastrequest` < 300

Posted: Sat Apr 14, 2007 12:28 pm
by guitarlvr
Jcart, where does the "300" come from?

Wayne

Posted: Sat Apr 14, 2007 12:32 pm
by John Cartwright
300 seconds (5 minutes), sorry I should of specified. Set that to however many seconds you want before the user is considered inactive.

Posted: Sat Apr 14, 2007 1:04 pm
by chaser7016
My site is like Gmail, Ajax loading ...the back and forward buttons never come into play.

Would your suggestion work for such a site?

Posted: Sat Apr 14, 2007 1:57 pm
by John Cartwright
On your event listener, simply update the last request time each request. Same principle.