Logging in and out of logged in users

Is it possible when a user logs in to log out that logged in user in other browsers? This way I can only have one person use the account at the same time.

Thanks

1 Like

I'm thinking like storing a token somewhere on the browser and do so comparission.
For example, you login on browser1 and the token is token1, store it on your db with the userid.

Every page load/action (even on login step), it first check to the server (db) if there's another one, and if the same user has another one (token2) it means has logged on browser2 then return logout where there is a token1

1 Like

Maybe could do that through sockets if using node by forcing a logout via the connect action.

image

Never tried, just me thinking out loud, but perhaps send the user ID on login via the connect message and then force logout at recipient side when socket message received if the user id matches.

If storing sessions in the DB, what about removing any other sessions containing the same user ID during the login process? This is about the simplest option I reckon.

Perfect, I'll try each of these solutions, thank you very much guys!

1 Like