About Online User Counter

If you have been wondering about how online user counters work, I would share my five cents worth of knowledge.

It detects the number of users online by tracking their IP addresses. Each IP address will be stored for an amount of time, unless the visitor triggers the script again and the counter restarts. At the same time, the script will count for the number of IP addresses stored to determine the number of users “online”.

A problem arouses when multiple IP addresses are detected from a visitor and the number of count exceeds the correct amount. This is the reason why a few months ago, sometimes you can see the number of my website’s online visitors reaching more than twenty.

For most free online scripts hosted by free service providers, they store each visiting IP address for fifteen minutes; however, in order to save bandwidth, they do not provide auto refreshing. A regular visitor will not stay in a blog for more than five minutes and thus the storing of IP addresses for fifteen minutes will be very inaccurate, on the other hand, will be very flattering for the owner.

The greatest problem about free service providers is that when their bandwidth has reached the limit or their server is down, the browser will take some time to try and load the script before it gives up, such that, visitors might think it is the problem with your website and give up waiting.

In order to solve the problems of inaccuracy, especially for the multiple IP addresses problem, I have implemented a free online PHP script in my webhost, which is adjustable. Since I have limited each storing of IP address to be only five seconds and with its auto-refresh function, the inaccuracy counted by time is at most five seconds.

For my website, it is displayed as “X readers online”.

Leave a Reply

Your email address will not be published. Required fields are marked *