NUmber of Users online

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
Supercops
Forum Newbie
Posts: 3
Joined: Mon Jul 13, 2009 5:05 pm

NUmber of Users online

Post by Supercops »

Hello All

Could you please let me know of any good php script that tell us the number os the users online on that Website . ?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Re: NUmber of Users online

Post by Skara »

To accurately gauge this, you would need ajax. However, all you'd really need to do to get a good estimate is log an IP with a timestamp in a database. After ~5 minutes have gone by, if that timestamp hasn't updated, delete the entry.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: NUmber of Users online

Post by jackpf »

That's almost identical to what I do. It's pretty cool: http://jackpf.co.uk. Check it out if you so desire.

I don't use ajax though, it just seems like pointless server load...I just define a user as online if they've requested a page in the last ten minutes.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: NUmber of Users online

Post by Ollie Saunders »

You don't need AJAX for this

First thoughts: You'll need to ubiquitously collect data on users that are online or not, involving sessions and some form of persistence and access to the persistence. The only way you could make this into a reusable "script" or library, as you're looking for Supercops, is if the site is using a MVC style system i.e. all requests are coming in at one point.

You cannot do this without access to the server. If you want to find out how many people are on a site you do not own you have little chance and even if you could do it you'd probably be breaking a law in the process, so don't! :-)
Post Reply