Answer the question
In order to leave comments, you need to log in
How to correctly count online on the site?
It is necessary to implement a count of active users on the site at the moment. It is not necessary to count those who opened the site and forgot about it for half a day. At what it would be desirable to make updating in real time. That is, if, for example, a person closes the tab, then it will immediately be displayed to others. I will update the value through web sockets, so the main thing is to count online on the server on time, competently and with good performance.
Answer the question
In order to leave comments, you need to log in
в afterAction контроллеров юзеру присваивать переменную lastActive в которую писать unix метку времени, например в базу ее писать. Потом делать выборку пользователей у которых lastActive больше, чем сейчас минус 15 минут например.
Можно вынести это в поведение или в компонент и подключить в конфиге.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question