Answer the question
In order to leave comments, you need to log in
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
Store the current session hash with the user. With each request, check for compliance. If the hashes do not match - forced logout.
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 questionAsk a Question
731 491 924 answers to any question