当前位置:网站首页>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 .
边栏推荐
- Student achievement management system (C language)
- Day06 list job
- Performance test process
- 20 kinds of hardware engineers must be aware of basic components | the latest update to 8.13
- DNS hijacking
- Error C4996 ‘WSAAsyncSelect‘: Use WSAEventSelect() instead or define _ WINSOCK_ DEPRECATED_ NO_ WARN
- Polymorphic system summary
- Aike AI frontier promotion (2.14)
- SQL greatest() function instance detailed example
- Quick sort (C language)
猜你喜欢

Climb Phoenix Mountain on December 19, 2021

SQL greatest() function instance detailed example

Hidden C2 tunnel -- use of icmpsh of ICMP

Quick sort (C language)

Appscan installation steps

Canoe: what is vtsystem

Digital simulation beauty match preparation -matlab basic operation No. 6

Huge number (C language)

TS type gymnastics: illustrating a complex advanced type

XMIND installation
随机推荐
MFC document view framework (relationship between classes)
Deepmind proposed a Zuan AI, which specially outputs network attack language
The last month before a game goes online
Network connection (III) functions and similarities and differences of hubs, switches and routers, routing tables and tables in switches, why do you need address translation and packet filtering?
Canoe: the fourth simulation project -- bug debugging experience
Huge number (C language)
re. Sub() usage
Personal thoughts on the development of game automation protocol testing tool
守护进程Xinted和日志记录Syslogd
本地Mysql忘记密码的修改方法(windows)[通俗易懂]
Error C4996 ‘WSAAsyncSelect‘: Use WSAEventSelect() instead or define _ WINSOCK_ DEPRECATED_ NO_ WARN
How to quickly parse XML documents through C (in fact, other languages also have corresponding interfaces or libraries to call)
software test
[Galaxy Kirin V10] [server] grub default password
Object. Assign () & JS (= >) arrow function & foreach () function
Regular expression
Postman advanced
Advanced order of function
1. Circular nesting and understanding of lists
Safety testing aspects