Session&token based Auth Login method description

Source: Internet
Author: User

Session
    • The client sends a login request to the server, and the request contains the user name, password information
    • The server receives the request, and after the request is parsed, the user name and password are passed to the DB to verify that the user name is stored in the DB and that the password is correct (the password passed when the password is verified is encrypted with the cipher in db).
    • If the user exists and the password is correct, a session file is generated on the server based on user information, which is stored in the server's memory
    • Server return to client login success information and session_id, session_id stored in the client cookie
    • After each visit to the server, the request will be sent back with a cookie to the server
    • The server reads the SessionID in the cookie, in contrast to the session information in memory, if it exists and does not time out, and then reads the user's other information from the DB through the user information in the session.
Token
    • The client sends a login request to the server, and the request contains the user name, password information
    • The server receives the request, and after the request is parsed, the user name and password are passed to the DB to verify that the user name is stored in the DB and that the password is correct (when the password is encrypted, it is compared with the password in db when the password is passed).
    • If the user exists and the password is correct, a string of characters is calculated on the server based on user information (such as userid, expiration time, etc.) as token
    • Server return to client login success information and token (JSON form)
    • The next time the client accesses the server, this token is brought in the header information of the request.
    • The service side gets token after verifying the signature in token, verifying that token is issued by the server, has not been tampered with and within the validity period, through the user information in token to read the user's other information

Session&token based Auth Login method description

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.