当前位置:网站首页>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
边栏推荐
- 1.C语言初阶练习题(1)
- Mortal immortal cultivation pointer-1
- Write a program to simulate the traffic lights in real life.
- 使用Spacedesk实现局域网内任意设备作为电脑拓展屏
- (超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
- 学编程的八大电脑操作,总有一款你不会
- 20220211-CTF-MISC-006-pure_ Color (use of stegsolve tool) -007 Aesop_ Secret (AES decryption)
- 【九阳神功】2017复旦大学应用统计真题+解析
- [during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
- 3. C language uses algebraic cofactor to calculate determinant
猜你喜欢
Mortal immortal cultivation pointer-1
1. C language matrix addition and subtraction method
5.函数递归练习
关于双亲委派机制和类加载的过程
(original) make an electronic clock with LCD1602 display to display the current time on the LCD. The display format is "hour: minute: Second: second". There are four function keys K1 ~ K4, and the fun
FAQs and answers to the imitation Niuke technology blog project (II)
受检异常和非受检异常的区别和理解
FAQs and answers to the imitation Niuke technology blog project (III)
仿牛客技术博客项目常见问题及解答(三)
【手撕代码】单例模式及生产者/消费者模式
随机推荐
优先队列PriorityQueue (大根堆/小根堆/TopK问题)
更改VS主题及设置背景图片
深度强化文献阅读系列(一):Courier routing and assignment for food delivery service using reinforcement learning
A piece of music composed by buzzer (Chengdu)
Why use redis
5.MSDN的下载和使用
[the Nine Yang Manual] 2016 Fudan University Applied Statistics real problem + analysis
Cookie和Session的区别
The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng
西安电子科技大学22学年上学期《基础实验》试题及答案
ABA问题遇到过吗,详细说以下,如何避免ABA问题
凡人修仙学指针-2
Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems
The latest tank battle 2022 full development notes-1
Service ability of Hongmeng harmonyos learning notes to realize cross end communication
PriorityQueue (large root heap / small root heap /topk problem)
CorelDRAW plug-in -- GMS plug-in development -- Introduction to VBA -- GMS plug-in installation -- Security -- macro Manager -- CDR plug-in (I)
The latest tank battle 2022 - full development notes-3
【九阳神功】2018复旦大学应用统计真题+解析
The difference between overloading and rewriting