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 has been logged on

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.