Online Indicator php code?

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
chaser7016
Forum Commoner
Posts: 34
Joined: Sat Nov 04, 2006 3:22 pm

Online Indicator php code?

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

Jcart, where does the "300" come from?

Wayne
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
chaser7016
Forum Commoner
Posts: 34
Joined: Sat Nov 04, 2006 3:22 pm

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

On your event listener, simply update the last request time each request. Same principle.
Post Reply