this question puzzled me for a long time. Mini Program takes too long to start checking login status (using wx.checkSession) and loads a lot of page data, which is very slow to display.
I now set the custom login state 3rd_session to be valid for 3 days on the backend, and cache it locally. Each time I open the user center page, read the local 3rd_session to determine whether I have logged in. When the request request is involved, check whether the 3rd_session expires at the backend. If it expires, call the frontend to log in again. I wonder if this logic is correct?
there are some other troubles:
- what if the local cache is deleted or corrupted? (there is no official explanation on the validity of local cache, only that it will be deleted after a certain period of time. I don"t know how long it will take.)
- what if the user table data has been maliciously modified to affect normal order payment?
- if the restart of the backend failure is due to the failure of the validity period of the 3rd_session setting, do you want to reset it?