is Android app login successful after returning a token,token put in the database reasonable?

Source: Internet
Author: User
Tags php server
Token has an expiration date, once it has expired to delete it, how to automatically delete it? The backstage is written in PHP.

Reply content:

Token has an expiration date, once it has expired to delete it, how to automatically delete it? The backstage is written in PHP.

Save to Redis, set obsolete

Token validity Long Direct Deposit db, run job processing; short-term cache caching, whether it's a dedicated cache or a memory cache look at the amount of data and the financial resources.

Token has an expiration date, once it has expired to delete it, how to automatically delete it? The backstage is written in PHP.

Both client and server authenticate user login

  • Token is saved with a time-out expire. For example, if the login is invalid after 7,200 seconds, the PHP server will send token and time () +7200 parameters to the client when the login is successful. This only needs to check whether the current time is greater than expire can determine whether the login is still valid, do not need to delete manually.

  • At the same time, when the server login is successful, a session with expiration time is set, which can determine whether the user's login information is still valid by the presence of the session.

No need to save the database, you can search under Discuz encryption decryption

  • 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.