Php+ajax Login Jump Login Implementation Ideas _php skills

Source: Internet
Author: User

When our user is logged on to the system, the user name and password verification are backend authenticated. Moreover, the user login status is also to the backend settings, after querying the database, the user name and password is correct, then stored in the session of the UUID, each page needs to be judged according to the status of login to display the corresponding content, then determine whether there is a UUID this session, and the UUID is not empty For example, the head of the login button, in the not logged in state is to display the login button, after the login to display the user name and Avatar, these are to determine whether there is a UUID value (specifically implemented, relatively more complex).

Let's take this step again:

  1. Back-end Ajax sending username and password
  2. After the backend receives the username and password, the query database
  3. If the query fails, returns a JSON data such as: {"status": "1", msg: "Incorrect username or password"}
  4. If the query succeeds, store a value in the session, such as a UUID, and then return a JSON to the front end, such as: {"status": "0", msg: "Success"}
  5. The front-end JS received the returned data, judge the value of status, if status==0, then use window.location.href to jump; Other status codes are login failures, empty password boxes, let users re-enter

For example, login successfully jump to the home page, the first page of PHP or Java, you need to determine whether there is a UUID session

<nav>
  <?php if (isset ($_session[' uuid ')) &&!empty ($_session[' uuid ')):?>
    <!-- If a UUID exists, it is not NULL, indicating that the-->
    <a href= "#" > Mosquito </a>
  <?php Else?>
    <!--not logged in-->
    <input type= "button" value= "Login"/>
  <?php endif;?>
</nav>

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.