javascript - How to implement the principle of timeout and exit without operation after logging in to the website for a period of time, how to deal with it on the front end and the back end respectively?
How can I log out after logging in to the website for a period of time, for example, if there is no operation for 30 minutes?
What processing is required on the backend and frontend?
Front-end sends request
The backend gets the request, clears the session, and then redirects directly,
Or return the front-end response and let the front-end redirect
The meaning of the question is ambiguous
If the session takes effect during the operation and causes timeout redirection
You can put some tags in the response header, delete them if they are expired, or change them
In this way, when everything involves requests, you can find the effectiveness of the session and redirect the front end
For the front end, if the login times out, there will be a return value after the timeout. You can operate based on the return value, log out of the login page, close the web page, etc.