Answer the question
In order to leave comments, you need to log in
How to determine the users who are currently on the site?
How to determine the users who are currently on the site?
And how to keep a list of pages that a specific user has visited for a specific period?
Answer the question
In order to leave comments, you need to log in
Raise websockets, track onopen, onclose of the user
Write
a user poll and poll users by timeout by implementing ping pong (since there are options when there will be no onclose )
There
is no other option active during the last period of time
Writing a log of their visits.
And more or less accurately, then this is WebSocket
How to determine the users who are currently on the site?There are many options, the simplest is the ping method. On the back, create a storage (an array, a file, a database, it doesn’t matter) in which you add the user who came to the site and the entry timestamp. Further, at the front, every N seconds, you request the server for a script that updates the user's timestamp in storage. It is possible to receive in the same place in the answer all active. All. Error in N seconds.
And how to keep a list of pages that a specific user has visited for a specific period?Logs. It doesn't matter either the file or the database, whichever is more convenient. I went to the page - the time, url, user ID were recorded in the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question