php - Log out everywhere, where else I am logged in -


i use php sessions basis of user login system, successful login setting $_session['userid']. allows user log in same account multiple machines.

however, i'd implement following features:

  1. log out everywhere, similar stack overflow has.
  2. see else 1 logged in.

both require more session variable, , i'm willing put more information database accomplish these. standard way above?

create new database table store sessions, , instead of storing information directly in $_session, store id referring row in new session table. table can contain information ip address, username, , time of last activity.

your application should check sessions table against has in $_session, when remove rows in table particular user, every session invalidated, wherever is. can query rows belonging particular user, can show have active sessions.

you'll have start thinking handling user leaves session without explicitly logging out - possibly scheduled job runs every hour or day, clearing out session rows haven't had activity in period of time.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -