The company's development model is front-end cutting and PHP pages. I have been cutting pictures for several months. After work, I have been recharging myself intermittently (after all, I became a monk halfway). I also came into contact with the separation of front-end and back-end. , vue.js and other things. At this time, I thought of a problem. After the current backend is separated and the user logs in, the backend must give the frontend a specific key value (let’s call it that for the time being, because I don’t have a specific concept) To determine a specific user, so as to provide different interfaces for different users. So where should the front-end store the key value reasonably?
If you are in a good mood, you can answer it in detail. If you are too lazy to explain, you can give me a few keywords and I will try to search them myself. Thank you
给我你的怀抱2017-05-19 10:40:00
Each user will have his or her own token, and save the token in cookie. Some basic information of the user will be stored in sessionStorage or localStorage. If the verification is passed, token verification will be fine
漂亮男人2017-05-19 10:40:00
After the backend verifies the frontend login successfully, an encrypted token is returned
The front-end stores the token in cookie or localstorage, and brings the token with each request. If the back-end verification passes, the data will be returned. If the verification fails, the corresponding status will be returned