当前位置:网站首页>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
边栏推荐
- Talk about four cluster schemes of redis cache, and their advantages and disadvantages
- File operation command
- 2022聚合工艺考试题模拟考试题库及在线模拟考试
- Day-17 connection set
- 有什么类方法或是函数可以查看某个项目的Laravel版本的?
- How to reset Google browser? Google Chrome restore default settings?
- PHP calls the pure IP database to return the specific address
- Aosikang biological sprint scientific innovation board of Hillhouse Investment: annual revenue of 450million yuan, lost cooperation with kangxinuo
- What if the xshell evaluation period has expired
- [learn micro services from 0] [02] move from single application to service
猜你喜欢
Sorting, dichotomy
关于 appium 启动 app 后闪退的问题 - (已解决)
Leetcode brush questions: binary tree 19 (merge binary tree)
图形对象的创建与赋值
Leetcode skimming: binary tree 23 (mode in binary search tree)
Charles: four ways to modify the input parameters or return results of the interface
【无标题】
Day-19 IO stream
Aosikang biological sprint scientific innovation board of Hillhouse Investment: annual revenue of 450million yuan, lost cooperation with kangxinuo
Common knowledge of one-dimensional array and two-dimensional array
随机推荐
【从 0 开始学微服务】【00】课程概述
在字符串中查找id值MySQL
2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
Find ID value MySQL in string
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
【无标题】
Day-24 UDP, regular expression
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
飞桨EasyDL实操范例:工业零件划痕自动识别
Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
Steps of building SSM framework
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
mysql怎么创建,删除,查看索引?
Image pixel read / write operation
用mysql查询某字段是否有索引
- Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
详解ThinkPHP支持的URL模式有四种普通模式、PATHINFO、REWRITE和兼容模式
【无标题】
Day22 deadlock, thread communication, singleton mode
HZOJ #240. 图形打印四