With PHP How to implement only allow the administrator to log in, and the current administrator account if logged in will not allow others to log in!! For advice
Reply content:
With PHP How to implement only allow the administrator to log in, and the current administrator account if logged in will not allow others to log in!! For advice
Login success, immediately insert a record in the data table, there is login time, reply information expiration time and other information, the second person log in when Chaku authentication
Two int field The first record logged in timestamp the second record log out of the time stamp log on when the time is still to judge if the current time is greater than the logout timestamp indicates that no one is logged in now if the person who logged in previously did not exit then the key expired in the judgment session. Before the user if the operation must be re-login again at this time another person can also login do not know if I express clearly
You use a online field to record the current user status
Admin only, this is simple, you only set an account information, or directly in the code to write dead.
Previous Admin Account if you are logged in, you are not allowed to sign in
This should be to say: The same account can only be logged in one place at the same time?
Look upstairs. Two-bit solution: One is to set the validity period, but this does not solve the problem of "simultaneous" login in another place.
Second, record the log out time, the key question is how to record?
If you want to ensure real-time, you need to use the socket
If not so strict, you can use regular access.
Redis Storage Userid:sessionkey Key-value pairs, each request checks whether the current user ID corresponds to the sessionId is consistent with the current session