I have my own forum script in PHP (Yii2 in fact) and I want to show online users if the user logs out If you become active at the time of doing so it will be easy but the matter is not that. Most of the time users log in to their machines but they are not active. Here I can use the time limit (renewal of time with each request, and renewing time out of that time limit), but not after that?
Is any popular / better way to monitor online users in the forum?
A possible way to block user interface events in JavaScript and send an AJAX notification to the server Of course, it should be buffered, so that you do not flood with requests when the user moves the mouse ('Keydown mousemove scroll', function () {clearTimeout (notifyTimer); notifyTimer = setTimeout (function () To get {$.
$ ('body'). ('My-server.com/user-is-active');}, 60 * 1000);}) ;
On the server side, update the last-active
field in the user table with the existing timestamp. When displaying online users, select people who are last-active & gt; Now - 15 minutes
.
Comments
Post a Comment