How to Count Online Users on a Website

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

How can I count people online on a PHP website at the moment if they don't need to be registered?

+2


a source to share


4 answers


Use cookies to identify unique users and then just track the last access to the PHP page. Then come up with a timeout mechanism - for example, if they haven't accessed the page in 15 minutes, they will be removed from the account.



+3


a source


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



I would say that on Google, you can find many scripts and articles related to your query.

+1


a source


Treat them like an anonymous user. Assign an arbitrary user ID in the cookie. In your user interface, show all anonymous users "Guest".

0


a source


Just write the IP addresses along with the timestamp to a file. On page load, read this file, delete all entries for say 3 minutes, add current IP and count the lines, write the file back. Locking this file will be nice.

It's all. All of the other methods listed here are simply overpowered for such a trivial thing, imprecise in design, regardless of the method you use.

0


a source







All Articles