当前位置:网站首页>The difference between cookies and sessions
The difference between cookies and sessions
2022-07-06 13:40:00 【Wake up duck, did you program today?】
Cookie: It is a mechanism used by the client browser to save the data of the server , When accessing a web page through a browser, the server can send some state data as key-value In the form of Cookie Store in the client browser , Then the next time the client accesses the server, it will carry the data and send it to the server , The server can Cookie The contents carried in it can be identified
Session: A container object indicating that the session belongs to the server side. By default, it will request for each browser ,Servlet Each container will be assigned a Session object ,Session The essence of can be considered as a ConcurrentHashMap It can be used to store some state data generated by the current session ,Http Itself is a stateless agreement , In other words, the server does not know that the multiple requests sent by the client belong to the same user , therefore Session To make up for Http A deficiency of Statelessness .
Simply put, the server side can take advantage of Session To store a record of multiple requests generated by the client in the same session, then based on the server Session The storage mechanism of is combined with that of the client Cokkie Mechanism, we can implement a stateful Http agreement
working principle :
When the client accesses the server for the first time , The server side will create a session for this request and generate a unique SessionID To mark this session , Then the server puts this SessionID Write to the client browser Cookie Inside , It is used to save the client state , It will be carried every time in the subsequent request SessionID, The server can use this SessionID To identify the status of the current session .
On the whole Cookie It is the storage mechanism of the client , and Session It is the storage mechanism of the server

边栏推荐
- 2. C language matrix multiplication
- 7.数组、指针和数组的关系
- Redis cache obsolescence strategy
- 【毕业季·进击的技术er】再见了,我的学生时代
- Rich Shenzhen people and renting Shenzhen people
- 稻 城 亚 丁
- Differences among fianl, finally, and finalize
- [au cours de l'entrevue] - Comment expliquer le mécanisme de transmission fiable de TCP
- 5. Function recursion exercise
- 1.C语言初阶练习题(1)
猜你喜欢
随机推荐
Detailed explanation of redis' distributed lock principle
3.C语言用代数余子式计算行列式
强化学习系列(一):基本原理和概念
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
凡人修仙学指针-1
最新坦克大战2022-全程开发笔记-2
Voir ui plus version 1.3.1 pour améliorer l'expérience Typescript
Miscellaneous talk on May 27
MySQL锁总结(全面简洁 + 图文详解)
5.函数递归练习
抽象类和接口的区别
4.分支语句和循环语句
[中国近代史] 第九章测验
[面試時]——我如何講清楚TCP實現可靠傳輸的機制
[the Nine Yang Manual] 2022 Fudan University Applied Statistics real problem + analysis
2. Preliminary exercises of C language (2)
[中国近代史] 第六章测验
FAQs and answers to the imitation Niuke technology blog project (II)
1. C language matrix addition and subtraction method
这次,彻底搞清楚MySQL索引









