当前位置:网站首页>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

边栏推荐
- The latest tank battle 2022 full development notes-1
- MySQL中count(*)的实现方式
- (超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
- fianl、finally、finalize三者的区别
- [during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
- 抽象类和接口的区别
- Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
- C language Getting Started Guide
- Voir ui plus version 1.3.1 pour améliorer l'expérience Typescript
- [中国近代史] 第六章测验
猜你喜欢

优先队列PriorityQueue (大根堆/小根堆/TopK问题)

ABA问题遇到过吗,详细说以下,如何避免ABA问题

fianl、finally、finalize三者的区别

Questions and answers of "Fundamentals of RF circuits" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology

3.猜数字游戏

关于双亲委派机制和类加载的过程

MPLS experiment
![[hand tearing code] single case mode and producer / consumer mode](/img/b3/243843baaf0d16edeab09142b4ac09.png)
[hand tearing code] single case mode and producer / consumer mode

Change vs theme and set background picture

Leetcode.3 无重复字符的最长子串——超过100%的解法
随机推荐
4.分支语句和循环语句
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
List set map queue deque stack
Questions and answers of "Fundamentals of RF circuits" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
5月27日杂谈
2.初识C语言(2)
Mode 1 two-way serial communication is adopted between machine a and machine B, and the specific requirements are as follows: (1) the K1 key of machine a can control the ledi of machine B to turn on a
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
稻 城 亚 丁
View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
Cloud native trend in 2022
2022泰迪杯数据挖掘挑战赛C题思路及赛后总结
Cookie和Session的区别
重载和重写的区别
仿牛客技术博客项目常见问题及解答(二)
六种集合的遍历方式总结(List Set Map Queue Deque Stack)
仿牛客技术博客项目常见问题及解答(三)
[modern Chinese history] Chapter V test
一段用蜂鸣器编的音乐(成都)