当前位置:网站首页>Simple understanding of seesion, cookies, tokens
Simple understanding of seesion, cookies, tokens
2022-07-04 11:04:00 【Black demon fairy moon】
as everyone knows ,Http It's stateless , After accessing the server , Access the server again , The server does not know that you are visiting again , So how to ensure that the server knows that we have logged in ?
When we log in , The browser will pop up an option to remember me , After selection , The browser can get the user name and password , The next time you log in , The browser will fill the request with user name and password . This introduces the first concept :Cookie.
Cookie Work flow chart of :
After the browser sends the request to the server , The server returns a Cookie,Cookie It contains name and value, The next time the browser sends a request to the server , Can carry Cookie.
however , Put your user name and password in Cookie It's very unsafe , If hackers attack our computers , To obtain the Cookie, Then it's easy to expose our information . Hence the Seesion.
After the client sends a request including the user account name and password to the server ,, The server will issue Session Id, take Session Id adopt cookie In the form of , Pass to client , Next time, the client will carry cookie Request to access . When max-age When time arrives , The client will delete cookie. If the user still needs to log in , You can only re-enter your user name and password . This Session Id Store on the server side , If the server is still based on session Of cookie, When a large number of users visit , Then the server will have to store a lot of session id, But if there are polymorphic servers , Then share session Id To other servers , But sharing is not a good way , So it's here JWT token.
JWT Divided into three parts , One is header: Indicates how to generate a signature , One is payLoad: It stores specific data , Such as expiration date , One signature:header and payload Both will be encoded , Then combine header The algorithm inside encrypts , Generate signature information . Such a complete one jwt The information can be sent to the client . There is no storage on the server token, As for the use of redis cache token, It's because such access is faster .
So to conclude :Session Is born and stored on the server , The server dominates everything , however Cookie Is a data carrier , hold Session Put it in Cookie Send it to the client ,Cookie Follow in every http In request ,token Saved in the browser , The client dominates everything , Can be placed in Cookie perhaps Storage in , hold token It's like holding a token , Allow access to the server .
边栏推荐
- Canoe - the third simulation project - bus simulation - 3-1 project implementation
- Canoe: the difference between environment variables and system variables
- Performance test overview
- Getting started with window functions
- Discussion | has large AI become autonomous? Lecun, chief scientist of openai
- Take advantage of the world's sleeping gap to improve and surpass yourself -- get up early
- JMeter assembly point technology and logic controller
- How to deal with the relationship between colleagues
- [test theory] test the dimension of professional ability
- [Galaxy Kirin V10] [server] NFS setup
猜你喜欢

JMeter Foundation

Canoe test: two ways to create CAPL test module

Climb Phoenix Mountain on December 19, 2021

Introduction to canoe automatic test system

Postman interface test

Canoe - the third simulation project - bus simulation - 3-1 project implementation
![[Galaxy Kirin V10] [desktop and server] FRP intranet penetration](/img/54/7d1b8b7b8226e2820635dd04b92d1c.jpg)
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration

Learning XML DOM -- a typical model for parsing XML documents

Huge number multiplication (C language)

Elevator dispatching (pairing project) ③
随机推荐
[test theory] test phase analysis (unit, integration, system test)
Canoe: what is vtsystem
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration
Terms related to hacker technology
Network connection (II) three handshakes, four waves, socket essence, packaging of network packets, TCP header, IP header, ACK confirmation, sliding window, results of network packets, working mode of
Huge number (C language)
R built in data set
[Galaxy Kirin V10] [desktop] FTP common scene setup
MBG combat zero basis
[Galaxy Kirin V10] [server] set time synchronization of intranet server
Simple understanding of string
Fundamentals of software testing
Huge number multiplication (C language)
Deepmind proposed a Zuan AI, which specially outputs network attack language
Interview and lecture summary 1
array_ The contains() function uses
iptables导致Heartbeat脑裂
Performance test process
Dichotomy search (C language)
Canoe - the third simulation project - bus simulation - 2 function introduction, network topology