It depends on what kind of authentication your server uses. You have to ask the back-end personnel. If it is cookie authentication, there is no need to add special operations on the front-end.
If you want to authenticate the token, then each time you enter the page, call any interface that requires a token. If the call fails, it means you are not logged in. If the call is successful, it means you have logged in.
As long as you don’t clear the stored token or the token does not expire, you will be logged in automatically.
1. The front and back ends are not separated: the login status should be maintained by the back end; 2. The front and back ends are separated: after the user logs in successfully, the back end returns a token, and the front end stores the token locally (localstorage or cookie). Just bring the token with each request.
It depends on what kind of authentication your server uses. You have to ask the back-end personnel. If it is cookie authentication, there is no need to add special operations on the front-end.
If you want to authenticate the token, then each time you enter the page, call any interface that requires a token. If the call fails, it means you are not logged in. If the call is successful, it means you have logged in.
As long as you don’t clear the stored token or the token does not expire, you will be logged in automatically.
1. The front and back ends are not separated: the login status should be maintained by the back end;
2. The front and back ends are separated: after the user logs in successfully, the back end returns a token, and the front end stores the token locally (localstorage or cookie). Just bring the token with each request.