In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the concept of token in vue". In daily operation, I believe that many people have doubts about the concept of token in vue. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the concept of token in vue?" Next, please follow the editor to study!
In vue, token means "token", which is a string generated by the server and an identification of the client's request; when the user logs in for the first time, the server generates a token and returns it to the client. Later, the client only needs to request data with token, without the need to use a user name and password.
This article operating environment: windows10 system, Vue2.9.6 version, DELL G3 computer.
What is the token in vue?
What is token
Token, which means "token", is a string generated by the server as an identity for the client to make the request. When the user logs in for the first time, the server generates a token and returns the token to the client. Later, the client only needs to bring the token to request data, without the need to bring the user name and password again.
The composition of simple token; uid (unique identity of the user), time (timestamp of the current time), sign (signature, the first few bits of token are compressed into a certain length hexadecimal string by hashing algorithm. To prevent token leakage).
II. The role of token
1. Prevent form from being submitted repeatedly: the main idea is that when the client initializes (that is, just entering the page), the back-end code is called, and the back-end code generates a token, which is returned to the client. The client stores the token (you can use hidden fields in the Form form in the foreground to store the Token, or you can use cookie), and then compare the token in the request with the token in the session.
2. Used for authentication:
(1) Overview of identity authentication
Because HTTP is a stateless protocol, it doesn't know who accessed our application. Here, the user is regarded as the client, and the client uses the user name and password to authenticate, but the next time the client sends a request, it has to be verified again.
The general solution is: when the user requests to log in, if there is no problem, generate a record on the server, in which you can indicate who the logged-in user is, and then send the id of the record to the client. After receiving the id, the client stores the id in the cookie, and the next time the user sends the request to the server, he can bring the cookie, so that the server will verify the information in the cookie. See if the corresponding record can be found on the server. If so, it means that the user has passed the authentication, and the data requested by the user is returned to the client.
The process described above is to use session, and that id value is sessionid. We need to store the session generated for the user on the server side, and the session will be stored in memory, disk, or database.
At this point, the study of "what is the concept of token in vue" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.