当前位置:网站首页>Cookie and session comparison
Cookie and session comparison
2022-07-07 12:57:00 【LC181119】
cookie and session The same and the different :
- cookie Usually generated on the server , But it can also be generated on the client ,session It is generated on the server
- session Save the data information on the server side , It could be memory , file , Database and other forms ,cookie Save the data in the client's memory or file
- Single cookie The saved data cannot exceed 4K, Each site cookie There is a limit to the number of , such as IE8 by 50 individual 、Firefox by 50 individual 、Opera by 30 individual ;session Stored on the server , There is no capacity limit
- cookie Stored locally by the user , Can be easily accessed and modified , Low security ;session Store on server , To compare safety
- cookie There is a conversation cookie And persistent cookie, A session whose lifecycle is the browser session cookie Save in cache , Close the browser window and disappear , persistent cookie Saved on hard disk , Know that the set expiration time is exceeded ; With the server session Storage pressure increases , It will be cleaned regularly as needed session data
- session There is a lot of data in , Only will sessionID This item can be passed cookie Send to client for retention , The next time the client accesses , In the request message cookie It'll carry it automatically sessionID, So as to communicate with the session Association
cookie shortcoming :
1、 Use cookie To deliver the message , With cookie The increase of the number and the number of visits , It takes up a lot of network bandwidth , Imagine if cookie Occupy 200 byte , If one day PV There are hundreds of millions , How much bandwidth does it take ?
2、cookie Is not safe , because cookie It's stored on the client side , So these cookie It can be accessed , Settings can be added through plug-ins 、 modify cookie. So from that perspective , We're going to use sesssion,session Is to save data on the server , Only by cookie Pass a sessionId nothing more , therefore session More suitable for storing user privacy and important data
session shortcoming :
1、 Not easy to share across multiple servers , have access to session binding ,session Copy ,session Shared solutions
2、session Stored in the server , therefore session Too much will consume the performance of the server
cookie and session Each has its own advantages and disadvantages , In large Internet Systems , Use alone cookie and session It's not possible
边栏推荐
- Session
- ip2long之后有什么好处?
- 认养一头牛冲刺A股:拟募资18.5亿 徐晓波持股近40%
- 图形对象的创建与赋值
- Talk about four cluster schemes of redis cache, and their advantages and disadvantages
- Image pixel read / write operation
- Creation and assignment of graphic objects
- [difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
- HZOJ #235. 递归实现指数型枚举
- 明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
猜你喜欢

Cookie

图像像素读写操作

达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑

Lingyunguang of Dachen and Xiaomi investment is listed: the market value is 15.3 billion, and the machine is implanted into the eyes and brain

Go语言学习笔记-结构体(Struct)

Day-18 hash table, generic
![[statistical learning method] learning notes - support vector machine (Part 2)](/img/bc/bb4f809ff434fabc10f8e97f592fa7.png)
[statistical learning method] learning notes - support vector machine (Part 2)

ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型

Star Enterprise Purdue technology layoffs: Tencent Sequoia was a shareholder who raised more than 1billion

How to continue after handling chain interruption / sub chain error removed from scheduling
随机推荐
test
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
[binary tree] delete points to form a forest
Leetcode skimming: binary tree 23 (mode in binary search tree)
Go语言学习笔记-结构体(Struct)
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
Guangzhou held work safety conference
“新红旗杯”桌面应用创意大赛2022
What kind of methods or functions can you view the laravel version of a project?
Polymorphism, final, etc
opencv的四个函数
Aike AI frontier promotion (7.7)
HZOJ #240. Graphic printing IV
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
认养一头牛冲刺A股:拟募资18.5亿 徐晓波持股近40%
企业级自定义表单引擎解决方案(十二)--体验代码目录结构
广州市召开安全生产工作会议
PHP calls the pure IP database to return the specific address
.Net下極限生產力之efcore分錶分庫全自動化遷移CodeFirst
Find ID value MySQL in string