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

边栏推荐
- JS interview questions (I)
- 西安电子科技大学22学年上学期《信号与系统》试题及答案
- 【手撕代码】单例模式及生产者/消费者模式
- Change vs theme and set background picture
- Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
- 5月27日杂谈
- [the Nine Yang Manual] 2018 Fudan University Applied Statistics real problem + analysis
- 9. Pointer (upper)
- 7. Relationship between array, pointer and array
- Leetcode. 3. Longest substring without repeated characters - more than 100% solution
猜你喜欢

The overseas sales of Xiaomi mobile phones are nearly 140million, which may explain why Xiaomi ov doesn't need Hongmeng

6. Function recursion

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

MySQL锁总结(全面简洁 + 图文详解)

Cloud native trend in 2022

3.C语言用代数余子式计算行列式

(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)

C语言入门指南

仿牛客技术博客项目常见问题及解答(二)

2. Preliminary exercises of C language (2)
随机推荐
最新坦克大战2022-全程开发笔记-2
凡人修仙学指针-2
[modern Chinese history] Chapter V test
3. Number guessing game
[面试时]——我如何讲清楚TCP实现可靠传输的机制
MySQL事务及实现原理全面总结,再也不用担心面试
arduino+DS18B20温度传感器(蜂鸣器报警)+LCD1602显示(IIC驱动)
[面試時]——我如何講清楚TCP實現可靠傳輸的機制
Floating point comparison, CMP, tabulation ideas
[graduation season · advanced technology Er] goodbye, my student days
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
Aurora system model of learning database
[the Nine Yang Manual] 2017 Fudan University Applied Statistics real problem + analysis
MySQL lock summary (comprehensive and concise + graphic explanation)
View UI plus released version 1.2.0 and added image, skeleton and typography components
【九阳神功】2016复旦大学应用统计真题+解析
View UI plus releases version 1.1.0, supports SSR, supports nuxt, and adds TS declaration files
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
3.C语言用代数余子式计算行列式
vector