How to implement with PHP only allow the administrator to log in, and the current administrator account if logged in will not allow others to log in

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

  • Related Article

    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.