I just found out that stackoverflow has a link to logout every logged computers.
So..I thought about how to implement same functionality in PHP. I came up with using session_set_save_haldner to control write() method. In write() method, I can make a session file start with user’s username. For example, a user john might have session files john_kdkajdkak, and john_29039dla. When John clicks “Logout Everywhere”, I can write a code that finds filenames start with “john” then remove them to clear sessions.
are there any other better solutions? How did you implement it if you already made it work?
Use a database to persist session data.
Using
session_set_save_handleryou can roll your own database storage backend for user sessions – asessionsthat has auser_idforeign key, related to theuserstable. A “logout everywhere” button would trigger simpleDELETE FROM sessions WHERE user_id = 1234and invalidate every session for the user.You can also easily add in additional columns to the
sessiontable – to store the IP address of the session, for instance, so users can see where other sessions are logged in from.Use a database for flexibility and performance.