当前位置:网站首页>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
边栏推荐
- 【从 0 开始学微服务】【02】从单体应用走向服务化
- 明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
- HZOJ #235. Recursive implementation of exponential enumeration
- Go语言学习笔记-结构体(Struct)
- HZOJ #236. Recursive implementation of combinatorial enumeration
- Aosikang biological sprint scientific innovation board of Hillhouse Investment: annual revenue of 450million yuan, lost cooperation with kangxinuo
- 基于NeRF的三维内容生成
- 【无标题】
- 达晨与小米投的凌云光上市:市值153亿 为机器植入眼睛和大脑
- Shortcut key of Bash
猜你喜欢
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
ISPRS2021/遥感影像云检测:一种地理信息驱动的方法和一种新的大规模遥感云/雪检测数据集
Master formula. (used to calculate the time complexity of recursion.)
Leetcode skimming: binary tree 23 (mode in binary search tree)
人均瑞数系列,瑞数 4 代 JS 逆向分析
云检测2020:用于高分辨率遥感图像中云检测的自注意力生成对抗网络Self-Attentive Generative Adversarial Network for Cloud Detection
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
3D content generation based on nerf
Day-18 hash table, generic
visual stdio 2017关于opencv4.1的环境配置
随机推荐
通过Keil如何查看MCU的RAM与ROM使用情况
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
Sorting, dichotomy
Shortcut key of Bash
test
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
Connect to blog method, overload, recursion
[statistical learning method] learning notes - support vector machine (Part 2)
企业级自定义表单引擎解决方案(十二)--体验代码目录结构
How to continue after handling chain interruption / sub chain error removed from scheduling
[statistical learning methods] learning notes - Chapter 5: Decision Tree
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
File operation command
免费手机号码归属地API查询接口
Day-16 set
货物摆放问题
What if does not match your user account appears when submitting the code?
Ip2long and long2ip analysis
Conversion from non partitioned table to partitioned table and precautions
【从 0 开始学微服务】【02】从单体应用走向服务化