B
B
banny_name2015-10-03 14:45:44
PHP
banny_name, 2015-10-03 14:45:44

How to log out a user, activity history?

I understand approximately how to create an activity history, but I don’t quite understand how to log out a user if he is offline, and even if he is online, but from another PC.
Cookie authorization.
I think I'll have to do it in sessions and store them in a directory, and delete them in order to log out, am I right?
Please tell me how and what

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-10-03
@romteh

You can create a table with user sessions. And when logging in, record the id of the current session. If he logs in from another computer, a new session is generated and the old one is overwritten. Accordingly, if a user with such a session id is not in the database, then he is logged in elsewhere and can be logged out here.
It's the same with activity. With each action, record the current time (last activity time).
Well, on the page, every 30 seconds make a request to the server and check the current session and user activity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question