当前位置:网站首页>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 Nine Yang Manual] 2021 Fudan University Applied Statistics real problem + analysis
- Arduino+ water level sensor +led display + buzzer alarm
- [中国近代史] 第六章测验
- 9. Pointer (upper)
- (超详细二)onenet数据可视化详解,如何用截取数据流绘图
- IPv6 experiment
- 甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
- Redis cache obsolescence strategy
- 6. Function recursion
- 【毕业季·进击的技术er】再见了,我的学生时代
猜你喜欢

【手撕代码】单例模式及生产者/消费者模式

PriorityQueue (large root heap / small root heap /topk problem)

甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1

凡人修仙学指针-1

深度强化文献阅读系列(一):Courier routing and assignment for food delivery service using reinforcement learning

IPv6 experiment

MPLS experiment

Pit avoidance Guide: Thirteen characteristics of garbage NFT project

20220211-CTF-MISC-006-pure_ Color (use of stegsolve tool) -007 Aesop_ Secret (AES decryption)

Mortal immortal cultivation pointer-2
随机推荐
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
Miscellaneous talk on May 27
7. Relationship between array, pointer and array
arduino+水位传感器+led显示+蜂鸣器报警
MySQL事务及实现原理全面总结,再也不用担心面试
The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng
Cookie和Session的区别
8. C language - bit operator and displacement operator
MySQL lock summary (comprehensive and concise + graphic explanation)
3.猜数字游戏
FileInputStream和BufferedInputStream的比较
5. Function recursion exercise
[modern Chinese history] Chapter V test
string
稻 城 亚 丁
1.C语言矩阵加减法
The latest tank battle 2022 - Notes on the whole development -2
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
MySQL中count(*)的实现方式
【九阳神功】2020复旦大学应用统计真题+解析