Page 1 of 1

How many people on page?

Posted: Tue Sep 14, 2010 9:44 am
by GeXus
This may be a simple question, but how do you determine how many people are accessing a given page at a given time?

It's important that the number is accurate, so I don't want to set sessions that expire, and assume 30 minutes or something along those lines. But rather, the exact number of people that are accessing a particular file/page at a given time....

Any direction would be huge! Thank you.

Re: How many people on page?

Posted: Tue Sep 14, 2010 3:01 pm
by buckit
The only real way is to use sessions. you can use javascript/ajax to run a php script that kills the session when the window closes... but that greatly determins on the browser settings.

Unfortunately there is no 100% accurate way... php is server side and the user leaving your site is client side. javascript is the only way to make the 2 sides talk.

Re: How many people on page?

Posted: Tue Sep 14, 2010 3:29 pm
by cpetercarter
A possible way is to keep a count (in a database) of unique IP addresses of visitors - deleting records more than, say, 1 hour old - and then make some heroic assumption such as that IP addresses which have requested one of your pages within the last 5 minutes are 'online'.