Vue project uses cookie for login verification, what is the expiration time?

use cookie for login verification, what if cookie is still valid after the window is closed? the nuxt project cannot get session, so it is done with cookie. The problem is how to disable cookie if you want to close the current page?

Jul.22,2021

manually clear before each visit?


Preface: at present, there is no good way to monitor browser pages to close, forward and backward, and refresh is also a way to close and open the current page, so the idea is wrong. Since nuxt is used for ssr development, the focus of authentication should be placed on the server, which is more secure. Let me briefly talk about the train of thought
.
  1. frontend user logs in with user account information
  2. the server interprets the user and generates a secret key token to the front end,
  3. The
  4. front end gets the token storage (it suddenly occurred to me that your problem lies here, as if it was all nonsense, uh, go on), and store it in cookie or session (ps.. Why cookie can be used session cannot be used. It should be that some browsers session cannot be used. You can make a compatible version here)
  5. other APIs are requested with token, server plus an interceptor. If the token time expires without token, an agreed value is returned
  6. the front-end api IO also acts as an interceptor to determine whether the agreed status value is not logged in. If so, delete the token and do some necessary logical processing
Menu