App Login Status maintained

Source: Internet
Author: User

Reprint Address: http://www.jianshu.com/p/4b6b04244773

At present, most apps support long login, that is, after users log in once, if the user did not actively log off, clear the app cache data or uninstall the app, for a period of time or remain logged in. In general, there are three ways of doing this:

using token to achieve

After the app login is successful, the server will somehow generate N-bit strings as tokens, set an expiration date, store it on the server, and return token to the app.

The subsequent app sends the token when sending the request, each time the server side receives the request, must verify the token and the validity period, the token value pair and within the validity period, the server returns the desired result, otherwise returns the error message, prompts the user to log in again.

(most currently used in this way)

use cookies to achieve

After the app login is successful, the server creates a cookie that contains session_id and expires two attribute values, which are stored on the server and sent to the app.

Subsequent apps send a request with a cookie containing this session_id, each time the server side receives the request, to verify the session_id and validity period, session_id value pair and within the validity period, the server returns the desired result, otherwise returns an error message, Prompt the user to sign in again.

(This is similar to the way the browser authenticates)

using the user name and password to implement

After the app login is successful, each time the app sends the request, the user name and password are sent to the server, and the server verifies the user name and password each time it receives the request. If the user is not logged on or logged out, the user name and password are not sent to the server when the request is made.

App Login Status maintained

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.