当前位置:网站首页>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
边栏推荐
- Leetcode.3 无重复字符的最长子串——超过100%的解法
- MPLS experiment
- Mortal immortal cultivation pointer-2
- 【九阳神功】2021复旦大学应用统计真题+解析
- 【九阳神功】2022复旦大学应用统计真题+解析
- 【九阳神功】2020复旦大学应用统计真题+解析
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
- Write a program to simulate the traffic lights in real life.
- 【九阳神功】2017复旦大学应用统计真题+解析
- [au cours de l'entrevue] - Comment expliquer le mécanisme de transmission fiable de TCP
猜你喜欢
2. C language matrix multiplication
[au cours de l'entrevue] - Comment expliquer le mécanisme de transmission fiable de TCP
Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems
西安电子科技大学22学年上学期《信号与系统》试题及答案
View UI plus released version 1.2.0 and added image, skeleton and typography components
编写程序,模拟现实生活中的交通信号灯。
2.C语言初阶练习题(2)
5.MSDN的下载和使用
PriorityQueue (large root heap / small root heap /topk problem)
优先队列PriorityQueue (大根堆/小根堆/TopK问题)
随机推荐
View UI plus released version 1.3.1 to enhance the experience of typescript
[the Nine Yang Manual] 2020 Fudan University Applied Statistics real problem + analysis
Wei Pai: the product is applauded, but why is the sales volume still frustrated
[graduation season · advanced technology Er] goodbye, my student days
(原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。
There is always one of the eight computer operations that you can't learn programming
2.初识C语言(2)
ABA问题遇到过吗,详细说以下,如何避免ABA问题
hashCode()与equals()之间的关系
Floating point comparison, CMP, tabulation ideas
Comparison between FileInputStream and bufferedinputstream
C语言入门指南
FAQs and answers to the imitation Niuke technology blog project (III)
1.C语言矩阵加减法
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s access to the Internet of things platform, upload real-time data collection /tcp transparent transmission (and how to obtain and write L
String abc = new String(“abc“),到底创建了几个对象
学编程的八大电脑操作,总有一款你不会
使用Spacedesk实现局域网内任意设备作为电脑拓展屏
这次,彻底搞清楚MySQL索引
Write a program to simulate the traffic lights in real life.