当前位置:网站首页>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
边栏推荐
- vector
- 1. C language matrix addition and subtraction method
- The latest tank battle 2022 full development notes-1
- Detailed explanation of redis' distributed lock principle
- FAQs and answers to the imitation Niuke technology blog project (I)
- hashCode()与equals()之间的关系
- 仿牛客技术博客项目常见问题及解答(二)
- [modern Chinese history] Chapter 9 test
- 学编程的八大电脑操作,总有一款你不会
- 编写程序,模拟现实生活中的交通信号灯。
猜你喜欢
更改VS主题及设置背景图片
Mortal immortal cultivation pointer-1
C语言实现扫雷游戏(完整版)
1.初识C语言(1)
(原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。
西安电子科技大学22学年上学期《基础实验》试题及答案
4.分支语句和循环语句
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
MySQL lock summary (comprehensive and concise + graphic explanation)
This time, thoroughly understand the MySQL index
随机推荐
Voir ui plus version 1.3.1 pour améliorer l'expérience Typescript
This time, thoroughly understand the MySQL index
西安电子科技大学22学年上学期《信号与系统》试题及答案
Change vs theme and set background picture
Floating point comparison, CMP, tabulation ideas
MySQL lock summary (comprehensive and concise + graphic explanation)
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
【九阳神功】2016复旦大学应用统计真题+解析
一段用蜂鸣器编的音乐(成都)
[the Nine Yang Manual] 2016 Fudan University Applied Statistics real problem + analysis
2.初识C语言(2)
JS interview questions (I)
仿牛客技术博客项目常见问题及解答(三)
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
Aurora system model of learning database
5.MSDN的下载和使用
Differences among fianl, finally, and finalize
3. Number guessing game
IPv6 experiment
最新坦克大战2022-全程开发笔记-3