当前位置:网站首页>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 .
边栏推荐
- 2、 Operators and branches
- TS type gymnastics: illustrating a complex advanced type
- Climb Phoenix Mountain on December 19, 2021
- Fundamentals of software testing
- Usage of case when then else end statement
- How to use diff and patch to update the source code
- Simple understanding of string
- 守护进程Xinted和日志记录Syslogd
- MBG combat zero basis
- Elevator dispatching (pairing project) ①
猜你喜欢
Appscan installation error: unable to install from Net runtime security policy logout appscan solution
Oracle11g | getting started with database. It's enough to read this 10000 word analysis
JMeter correlation technology
Canoe - description of common database attributes
Climb Phoenix Mountain on December 19, 2021
Canoe - the third simulation project - bus simulation - 3-2 project implementation
[Galaxy Kirin V10] [server] NFS setup
Post man JSON script version conversion
Add t more space to your computer (no need to add hard disk)
Performance test method
随机推荐
Fundamentals of database operation
[Galaxy Kirin V10] [server] grub default password
Capl: timer event
How to quickly parse XML documents through C (in fact, other languages also have corresponding interfaces or libraries to call)
Heartbeat报错 attempted replay attack
Quick sort (C language)
PHP programming language (1) - operators
Jemeter script recording
Function introduction of canbedded component
Canoe test: two ways to create CAPL test module
守护进程Xinted和日志记录Syslogd
[Galaxy Kirin V10] [desktop] FTP common scene setup
[Galaxy Kirin V10] [server] set time synchronization of intranet server
Const's constant member function after the function; Form, characteristics and use of inline function
Locust installation
[Galaxy Kirin V10] [server] system startup failed
Locust learning record I
Detailed array expansion analysis --- take you step by step analysis
Performance test overview
DNS hijacking