Generally, the backend pushes the message to the frontend, and the frontend is only responsible for prompting the user and jumping back to the login page. There are several push methods: websocket; polling; message queue;
This issue needs to be discussed with your backend.
If it is not a single-page system and involves page jumps, the backend has the ability to control redirection. Whether the user wants to be kicked out is also decided by the backend.
If it is an asynchronous interface that needs to be intercepted, directly let the backend return a non-login error code.
The function of logging in and kicking people at the same time has nothing to do with the front-end. The back-end tells me that the user is logged in, so he is logged in. The back-end interface returns to us that the user's login is invalid, then we will prompt the corresponding information and control the jump. change.
================== This kicking function is originally a matter of the entire system. What is your system like? Is it a single-page system? Kicking people must be done. Real-time, what plan has been adopted for the back-end, these things are not stated, just five big words "how to write the front-end" is an attempt to get technical help from others, I think it is ridiculous. When does the front end decide whether a user is logged in?
You can basically tell someone’s level by looking at the way they ask questions.
·Check whether the local tag is consistent with the server tag every time it is refreshed. The tags are obtained at intervals, depending on the specific situation ·Websocket cooperates with ajax to achieve real-time monitoring, not recommended, http stateless protocol.
The first method I use to eliminate login selections: every time a user logs in, a sign is generated and stored in the database, written to catch, and re-queried every 5 minutes. If the sign does not match, log out
Generally, the backend pushes the message to the frontend, and the frontend is only responsible for prompting the user and jumping back to the login page.
There are several push methods:
websocket;
polling;
message queue;
This issue needs to be discussed with your backend.
If it is not a single-page system and involves page jumps, the backend has the ability to control redirection. Whether the user wants to be kicked out is also decided by the backend.
If it is an asynchronous interface that needs to be intercepted, directly let the backend return a non-login error code.
The function of logging in and kicking people at the same time has nothing to do with the front-end. The back-end tells me that the user is logged in, so he is logged in. The back-end interface returns to us that the user's login is invalid, then we will prompt the corresponding information and control the jump. change.
==================
This kicking function is originally a matter of the entire system. What is your system like? Is it a single-page system? Kicking people must be done. Real-time, what plan has been adopted for the back-end, these things are not stated, just five big words "how to write the front-end" is an attempt to get technical help from others, I think it is ridiculous. When does the front end decide whether a user is logged in?
You can basically tell someone’s level by looking at the way they ask questions.
It’s all the uncles who ask questions these days.
==== Original answer ====
Use the keyboard, or else use a pen?
·Check whether the local tag is consistent with the server tag every time it is refreshed. The tags are obtained at intervals, depending on the specific situation
·Websocket cooperates with ajax to achieve real-time monitoring, not recommended, http stateless protocol.
The first method I use to eliminate login selections: every time a user logs in, a sign is generated and stored in the database, written to catch, and re-queried every 5 minutes. If the sign does not match, log out