Article From:https://segmentfault.com/q/1010000012428750
Question:

Ask a question, Taobao, we log in, and as long as we do not quit, we do not need to login again when we open the app next time. If I did not operate after visiting a web page, but session expired, then I also imagined that APP would not need to re login. Can let usersContinue to visit

Answer 0:

Well, are you going to visit session to expire?

Answer 1:

I remember that session can be set to turn off browser failure, you check.

Answer 2:

You can use JWT, out of session and cookie.
Reference: what is JWT

Answer 3:

The sessionId is stored in cookie, and the browser closes cookie is still existing, and the usual session expiration is actually the server side session expired, as long as the server’s session does not expire and the client’s sessIonId also exists, so you can take the sessionId from the client to the server’s session, so just set the server’s session to never expire. Remember me (remember me) is the sessioNId is stored in cookie.
Set session never expire:

session.setMaxInactiveInterval(-1);

Answer 4:

Talk about the storage mechanism:

1.cookie Not out of the background, 4KB storage2.session session level storage (turn off the page)3.local stroage (to be manually cleaned, otherwise it will always exist).4.indexDB (poor compatibility)So, with local stOrage can achieve your effect without landing

Link of this Article: The problem of session failure

Leave a Reply

Your email address will not be published. Required fields are marked *