当前位置:网站首页>Cookies and sessions
Cookies and sessions
2022-07-25 02:21:00 【Joy's sister is a rookie】
After we log in on the web , You can log in again for a long time , For example, bleep bleep 、CSDN
however http It's stateless , After closing the web page , Then the server doesn't know you at all
So for the better experience of the client , With Cookie and Session
Cookie
cookie Key value pair (key-value) Express
cookie Yes 2 Storage methods , One is conversational , One is persistence .
Conversational : If cookie For conversational , that cookie It will only be saved in the memory of the client , When we close the customer service terminal cookie It's not working .
persistence : If cookie For persistence , that cookie Will be saved on the user's hard disk , Until the end of its lifetime or the user actively destroys it .
Cookie Just some data , It is used to store the information returned by the server to the customer service side , The client saves . The next time you visit the site , The client will save it cookie Send it to the server together , Server reuse cookie Do something . utilize cookie We can achieve automatic login , Save your tour history , Authentication and other functions .
The process :
The browser initiates to the server HTTP request
Server run Set-Cookie(Cookie Name and value attributes , The server fills the contents of the two attributes completely )
Server will Cookie After sending it to the browser , Browser save
In the future, each request of the browser will be automatically attached Cookie( namely Cookie Is the data stored in the browser )
but Cookie Very unsafe ( Open the browser and you will see )
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-z790D37j-1658278651488)(C:\Users\pon18\AppData\Roaming\Typora\typora-user-images\image-20220719214036577.png)]](/img/b0/d483694ccd822a30bb45b476578677.png)
Session conversation
Browser access to the server is the beginning of the session , The end time of the session is vague , So the server sets the time ( Time the session ended ) And the only ID(Session ID)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-TqhLtspU-1658278651491)(C:\Users\pon18\AppData\Roaming\Typora\typora-user-images\image-20220719214012917.png)]](/img/56/7a2d4200018490f9285f476cc3ffca.png)
After receiving the user name and password, the server verifies that it is correct
Will create a Session ID And session end time , Open up a piece of memory to store all of the server session
Set up Cookie, take Session ID Add to Cookie in , Then set the end time of the session to Cookie The validity of the
Every session Will have a unique identification session ID, According to the client cookie Medium session ID, Find the corresponding server side session.
In order to prevent server-side session Too much leads to memory overflow ,web By default, the server will give each session Set an expiration date , (30 minute ) If the client has not accessed the within the validity period session, The server considers the client offline and deletes the session.
边栏推荐
- [hero planet July training leetcode problem solving daily] 20th BST
- Summary thinking caused by the function of a SMS verification code [easy to understand]
- JS utils tool function that makes you get twice the result with half the effort
- How to communicate with aliens
- About the relationship between parent process and child process (UAC bypass idea)
- Example demonstration of "uncover the secrets of asp.net core 6 framework" [02]: application development based on routing, MVC and grpc
- Digital commerce cloud fine chemical industry management platform integrated informatization solution
- Babbitt | metauniverse daily must read: Dubai launched the national metauniverse strategy, which plans to increase the number of related companies of metauniverse by five times in the next five years
- PostgreSQL views tables, table indexes, views, table structures, and parameter settings
- Research and application of scientific data management strategy for high energy synchrotron radiation source
猜你喜欢

Peripherals: timer, watchdog and RTC

Four redis cluster schemes you must know and their advantages and disadvantages

What do growth enterprises need most to build a data-driven organization?

Focus on improving women's and children's sense of gain, happiness and security! In the next ten years, Guangzhou Women's and children's undertakings will make such efforts

Several application scenarios of NAT

Use Fiddler to capture apps

Detailed explanation of manually writing servlet in idea
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/26/18fd3106f887f503479f081e29dac3.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

Industrial control safety PLC firmware reverse II

Use SAP ui5 application to consume create and delete operations of OData in business application studio
随机推荐
Consul cluster deployment
What are the important trends revealed by the release of "operator data viability index"?
PostgreSQL views tables, table indexes, views, table structures, and parameter settings
Win10 configuring CUDA and cudnn
Inventory of well-known source code mall systems at home and abroad
Deamnet|filenotfounderror: [winerror 3] the system cannot find the specified path.: '/ Datasettest\\Set12‘
Detailed explanation of MySQL, Oracle and PostgreSQL database index failure scenarios
Arthas case: dynamic update application logger level
Peripherals: interrupt system of keys and CPU
Agreement on sharing agricultural scientific data in China
These 11 chrome artifacts are extremely cool to use
Web vulnerability
Beijing Zhun electric clock, Beidou clock server, GPS network time server, NTP satellite timing system
How MySQL 8.0 based on TRX_ Id find the statement of the whole transaction
JS utils tool function that makes you get twice the result with half the effort
Detailed explanation of manually writing servlet in idea
Standard transfer function
Can PostgreSQL CDC only connect to the main database? Connection from the library reports an error logical decoden
SetTimeout parameters [easy to understand]
G024-db-gs-ins-01 openeuler deployment opengauss (single instance)