Answer the question
In order to leave comments, you need to log in
How to implement the last time online function?
Hello, I am making a site on nodeJs and postgresql, I use sessions for authorization and Redis cache storage. How can I implement the function when the user was last online?
Answer the question
In order to leave comments, you need to log in
With each action / authorization / something else of the user, write down in the database that he was online. You can then use this information wherever you need it.
Create a last_seen column and add a timestamp there when requesting session initialization.
Make a websocket in which the online label is reset on the first connection, and when the connection is lost and there are no other active ones, the last activity label is put
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question