Simple Script to know how many users are online on the site?

Friends, is there any simple script in php (or some other solution for linux php/mysql server) to know how many users are online on the site? I read that websocket is good for chats. In my case, it is not chat nor anything complex no. Just know even something like:

"xx users online at this time".

Also need not be every second, hehehe, but kind, every 1 minute or the best average between time and non-server overhead.

This issue of not overloading the server with requests is important. I was wondering if you have any simple solution that requires as little server and data transfer as possible (I'm using Shared Hosting for now). The expectation is already to have a script that can meet a huge demand of visitors in the future at the same time without overloading the server (when it comes to this, I expect to be with dedicated server).

Any help is valid! Thank you very much!

Author: Peter, 2018-01-07

1 answers

Making an online user counter on the site, however simple it may be, is a task with a certain level of complexity. In addition to having to do a somewhat laborious programming in sync of JavaScript with PHP and use database, you will have to do IP control, know when a user has entered or left the site etc.

If you want an easy solution to later try something of your own or more robust, I suggest using the Supercounters. It is a free webservice and not you need a record. Just insert into your site a small code generated in the service, something like this:

<!-- BEGIN: Powered by Supercounters.com -->
<center>
<script type="text/javascript" src="//widget.supercounters.com/ssl/online_t.js"></script>
<script type="text/javascript">sc_online_t(1467207,"Users Online","170ddb");</script>
<br><noscript><a href="http://www.supercounters.com/">Free Users Online Counter</a></noscript>
</center>
<!-- END: Powered by Supercounters.com -->

This code will show how many users are online, and also provides a link where you have a report on the Access: country of the user, origin of the Access (referer), access number per day, time of access, user OS, screen resolution, browser among others.

 3
Author: Sam, 2018-01-07 12:37:02