How can I use PHP to allow only the administrator to log on? if the current administrator account has been logged on, no one else is allowed to log on !! How to use PHP to allow only the administrator to log on, and the current administrator account cannot allow others to log on if it is already logged on !! Tutorial
Reply content:
How can I use PHP to allow only the administrator to log on? if the current administrator account has been logged on, no one else is allowed to log on !! Tutorial
Log on successfully. Insert a record in the data table immediately, including the logon time and reply message Expiration Time. check the database for verification when the second user logs on.
Two int fields, the first record logon timestamp, the second record logout timestamp, and the time to be judged when logging in. if the current time is greater than the logout timestamp, no one logged in now. if the user does not exit, the key in the session expires. if the user does not exit, the user must log on again. at this time, the user can log on again. I wonder if I have made it clear.
You can use an online field to record the current user status.
Only administrator management is allowed. this is very simple. you can set only one account information or directly write it to the code.
The previous administrator account is not allowed to be logged on if it is already logged on.
It should be said that the same account can only log on to the same region at the same time?
I have read the two solutions provided by the upstairs: one is to set the validity period, but this cannot solve the problem of "simultaneous" login in another place.
Second, how to record the logout time?
To ensure real-time, you need to use socket
If not, you can use timed access.
Redis stores the key-value pair of userId: sessionKey. each request checks whether the sessionId corresponding to the current user ID is consistent with the current session