tags:

views:

128

answers:

4

Possible Duplicates:
script to tell me who, and how many users, are online
Best way to keep track of current online users

How should I count the people online on a PHP website at a given time, if they don't have to be logged-in?

A: 

Treat them as anonymous user. Assign a random user ID in a cookie. In your UI, show all the anonymous users as "Guest".

ZZ Coder
A: 

Use a cookie to identify unique users, and then just keep track of the last time accessed a PHP page. Then come up with a timeout mechanism - for example, if they have not accessed a page in 15 minutes then they are removed from the count.

This article provides some code and info on using cookies and PHP to track visitors.

Justin Ethier
A: 

bah, just write an IP addresses along with timestamp into a file.
on a page load read this file, delete all records, say, 3 minutes older, add current IP and count the lines. write the file back.
to lock this file would be nice.

that's all
all other methods listed here are just overpower for such a trifle thing, inaccurate by design, no matter the method you use

Col. Shrapnel
+1  A: 

http://www.devarticles.com/c/a/PHP/The-Quickest-Way-To-Count-Users-Online-With-PHP/1/

I would say to google, you can a lot of scripts and articles related to your query.

Vinothbabu