CodePudding user response:
Forgot to say, the front is the vue framework, the backend is springbootCodePudding user response:
Web log=& gt; Login request API=& gt; API returns the session/error message=& gt; Web caching session cookies and jump to login to access the page, each request API pass session to API test current stateRefresh the page of the web from a cookie session, the session when the parameter passed to the API request API inspection, failure to return to the login page, success continue to access the page,
CodePudding user response:
Request response will back sessionStorage. SetItem (" userID ", userID); Stored in the session, if you need to login state can jump page, you can use axios request interception, request put the head or the login userId and status information what you need, request before judging whether satisfy the condition that you need, does not meet the jump to the login page, after login to enter the interface of need to log in toBefore I also wrote an article on the axios packaging with a request to intercept, you can refer to take a look at https://blog.csdn.net/weixin_45471782/article/details/100225111
CodePudding user response:
Request after using sessionStorage. SetItem to save data, and then join in the request method of encapsulation request interception, through the sessionStorage. The getItem method to collect data, have value to execute the request, did not return to the login page, also can be also judged by routing guard login status,Request to intercept intercept and routing guard how to use baidu, routing guard written I have written in the article, can go to have a look at