当前位置:网站首页>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
边栏推荐
- .Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
- Leetcode skimming: binary tree 23 (mode in binary search tree)
- Cmu15445 (fall 2019) project 2 - hash table details
- Cryptography series: detailed explanation of online certificate status protocol OCSP
- 测试下摘要
- 图形对象的创建与赋值
- 【从 0 开始学微服务】【01】什么是微服务
- [statistical learning methods] learning notes - Chapter 4: naive Bayesian method
- The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
- API query interface for free mobile phone number ownership
猜你喜欢
ISPRS2021/遥感影像云检测:一种地理信息驱动的方法和一种新的大规模遥感云/雪检测数据集
数据库安全的重要性
如何将 @Transactional 事务注解运用到炉火纯青?
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
NPM instal reports agent or network problems
Image pixel read / write operation
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
[statistical learning methods] learning notes - Chapter 5: Decision Tree
飞桨EasyDL实操范例:工业零件划痕自动识别
随机推荐
云检测2020:用于高分辨率遥感图像中云检测的自注意力生成对抗网络Self-Attentive Generative Adversarial Network for Cloud Detection
Day26 IP query items
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
[爬虫]使用selenium时,躲避脚本检测
test
谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
Grep of three swordsmen in text processing
环境配置篇
Day-18 hash table, generic
PHP calls the pure IP database to return the specific address
Unity 构建错误:当前上下文中不存在名称“EditorUtility”
关于 appium 启动 app 后闪退的问题 - (已解决)
通过Keil如何查看MCU的RAM与ROM使用情况
HZOJ #240. Graphic printing IV
初学XML
详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
ip2long之后有什么好处?
Cookie
Common knowledge of one-dimensional array and two-dimensional array
COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~