当前位置:网站首页>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 .
边栏推荐
- 本地Mysql忘记密码的修改方法(windows)
- Common system modules and file operations
- Usage of case when then else end statement
- [Galaxy Kirin V10] [server] NUMA Technology
- 本地Mysql忘记密码的修改方法(windows)[通俗易懂]
- Fundamentals of database operation
- Elevator dispatching (pairing project) ②
- Elevator dispatching (pairing project) ①
- Fundamentals of software testing
- regular expression
猜你喜欢
20 minutes to learn what XML is_ XML learning notes_ What is an XML file_ Basic grammatical rules_ How to parse
Learning XML DOM -- a typical model for parsing XML documents
Appscan installation error: unable to install from Net runtime security policy logout appscan solution
TS type gymnastics: illustrating a complex advanced type
How to use diff and patch to update the source code
Elevator dispatching (pairing project) ③
Canoe - the second simulation project -xvihicle1 bus database design (operation)
JMeter common configuration components and parameterization
Jemeter script recording
Personal thoughts on the development of game automation protocol testing tool
随机推荐
Dictionaries and collections
For and while loops
Interview and lecture summary 1
Appscan installation error: unable to install from Net runtime security policy logout appscan solution
Discussion | has large AI become autonomous? Lecun, chief scientist of openai
[test theory] test phase analysis (unit, integration, system test)
Notes on writing test points in mind mapping
Failed to configure a DataSource: ‘url‘ attribute is not specified... Bug solution
Safety testing aspects
Post man JSON script version conversion
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
[Galaxy Kirin V10] [server] FTP introduction and common scenario construction
MFC document view framework (relationship between classes)
Huge number multiplication (C language)
试题库管理系统–数据库设计[通俗易懂]
Getting started with window functions
Capl: timer event
Error C4996 ‘WSAAsyncSelect‘: Use WSAEventSelect() instead or define _ WINSOCK_ DEPRECATED_ NO_ WARN
Summary of automated testing framework
CAPL: on sysVar_ Update difference on sysvar