A
A
alestro2015-10-25 14:08:25
PHP
alestro, 2015-10-25 14:08:25

Sessions. How to destroy all sessions except the current one?

Actually, how is this implemented?
I meant how to exit all sessions, except for the one from which the exit is made.
Let's say there is a site, you are logged in from many devices and browsers, how to log out of all, except for the one from which the request was sent.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
index0h, 2015-10-25
@index0h

Store the current session hash with the user. With each request, check for compliance. If the hashes do not match - forced logout.

R
Rsa97, 2015-10-25
@Rsa97

By default in PHP, each session is stored in a separate file. To close them, it is enough to find these files and delete them. Browsers, however, will not know about this until they send the next request.
Another option is to store sessions in MySQL, for this you need to redefine the functions for working with sessions, for example : . In this case, it will be much easier to find the sessions of a particular user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question