How to block login on 2 devices?

Asked

Viewed 376 times

-1

I am developing a PHP application where the user can stay logged in even after signing out, using cookies. However, the user cannot stay connected to 2 devices simultaneously.

More specifically, what I’d like to know is: How do I make a session (or cookies from that other session) invalid when the user accesses from another device?

  • You can have a secondary table, and based on this, you register Idusuario, the time it is logged in and its status, if it is status 1, it is logged in on some device and cannot log in again, and if it is not, allows login, before checking the login and password, does the status check

  • @In case he can log in again, the system only needs to disable it on the first device. Hence the doubt.

  • Yes, if you do a SET status = 0, to depress, vc can make a script that checks the status, whenever it accesses some file and tals

  • This becomes complex when you want to deploy a device in real time when you log in to a second device. In that case you will have to use techniques such as long.

1 answer

-1

Considering that the information that is not enough to understand what is already done as mentioned and if asked to develop a system within what described my option was clearly by using tokens JWT.

For more information JSON Web Token

I already have several implementations with this type of mechanism and besides simple is very good for distributed systems or with many accesses. If you have any difficulty say.

  • JWT does not mitigate access on multiple devices.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.