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

边栏推荐
- ABA问题遇到过吗,详细说以下,如何避免ABA问题
- Floating point comparison, CMP, tabulation ideas
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
- String ABC = new string ("ABC"), how many objects are created
- MySQL锁总结(全面简洁 + 图文详解)
- MySQL lock summary (comprehensive and concise + graphic explanation)
- View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
- MySQL中count(*)的实现方式
- 最新坦克大战2022-全程开发笔记-2
- Why use redis
猜你喜欢

1.C语言初阶练习题(1)

2.初识C语言(2)

Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
![[hand tearing code] single case mode and producer / consumer mode](/img/b3/243843baaf0d16edeab09142b4ac09.png)
[hand tearing code] single case mode and producer / consumer mode

C language to achieve mine sweeping game (full version)

5. Download and use of MSDN

MySQL lock summary (comprehensive and concise + graphic explanation)

Pit avoidance Guide: Thirteen characteristics of garbage NFT project

凡人修仙学指针-1

Mode 1 two-way serial communication is adopted between machine a and machine B, and the specific requirements are as follows: (1) the K1 key of machine a can control the ledi of machine B to turn on a
随机推荐
3. C language uses algebraic cofactor to calculate determinant
MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
4. Binary search
这次,彻底搞清楚MySQL索引
20220211-CTF-MISC-006-pure_ Color (use of stegsolve tool) -007 Aesop_ Secret (AES decryption)
4.分支语句和循环语句
3.猜数字游戏
1.初识C语言(1)
The difference between abstract classes and interfaces
The latest tank battle 2022 full development notes-1
8. C language - bit operator and displacement operator
This time, thoroughly understand the MySQL index
(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
JS interview questions (I)
凡人修仙学指针-2
Caching mechanism of leveldb
1. C language matrix addition and subtraction method
Redis实现分布式锁原理详解
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)