当前位置:网站首页>Localstorage and sessionstorage
Localstorage and sessionstorage
2022-07-27 03:09:00 【IO unintentional】
cookie/localStorage/sessionStorage The difference between
- The storage method is different :cookie Data is always in the same source http Carry... In the request , namely cookie It will pass back and forth between the browser and the server , However, you can restrict it to be valid only under a certain path through the path . and sessionStorage and localStorage It doesn't send data to the server , Save locally only .
- Storage size limits vary :cookie Data cannot exceed 4K, Only suitable for keeping small data , Such as session ID .sessionStorage and localStorage The size that can be stored is 5M about .
- Data validity is different :sessionStorage Only valid until the current browser window is closed ;localStorage Always effective , Windows or browsers are closed and saved all the time ;cookie Only in settings cookie Valid until expiration date , Even if the window or browser is closed .
- Different scopes :sessionStorage Don't share in different browser windows , Even if it's the same page ;localStorage and cookie Share... In all homologous windows .
localStorage Methods
- localStorage.setItem("key","value"); Add a key value pair
- localStorage.getItem("key"); adopt key Inquire about value
- localStorage.removeItem("key"); Delete key Corresponding key value pair
- localStorage.clear(); Clear all key value pairs
sessionStorage Methods ( And localStorage The method is the same )
- sessionStorage.setItem("key","value"); Add a key value pair
- sessionStorage.getItem("key"); adopt key Inquire about value
- sessionStorage.removeItem("key"); Delete key Corresponding key value pair
- sessionStorage.clear(); Clear all key value pairs
边栏推荐
- Ten thousand words long text, take you to understand the kubernetes network model
- Okaleido Tiger 7.27日登录Binance NFT,首轮已获不俗成绩
- Redis四大特殊数据类型的学习和理解
- 阿里云技术专家杨泽强:弹性计算云上可观测能力的构建
- ansible系列之:不收集主机信息 gather_facts: False
- iNFTnews | GGAC联合中国航天ASES 独家出品《中国2065典藏版》
- [Ryu] common problems and solutions in installing Ryu
- Skywalking系列学习之告警通知源码分析
- 2513: 小勇学分数(公约数问题)
- 朴素贝叶斯——文档分类
猜你喜欢

云开发寝适闹钟微信小程序源码

185. 部门工资前三高的所有员工(必会)

Favicon web page collection icon online production PHP website source code /ico image online generation / support multiple image format conversion

阿里云解决方案架构师张平:云原生数字化安全生产的体系建设

Complete source code of mall applet project (wechat applet)

Plato Farm通过LaaS协议Elephant Swap,为社区用户带来全新体验

五、MFC视图窗口和文档
全网最全的软件测试基础知识整理(新手入门必学)

QT编译出来的exe以管理员权限启动

机器学习【Matplotlib】
随机推荐
[SQL简单题] LeetCode 627. 变更性别
Manually build ABP framework from 0 -abp official complete solution and manually build simplified solution practice
vs2019 中编译和使用 protobuf 库
[binary search medium] leetcode 34. find the first and last positions of elements in the sorted array
Goatgui invites you to attend a machine learning seminar
对象创建的流程分析
素因子分解--C(gcc)--PTA
云开发寝适闹钟微信小程序源码
智能指针shared_ptr、unique_ptr、weak_ptr
[dynamic planning medium] leetcode 198. looting 740. delete and get points
MarqueeView实现滑动展示效果
cocos小游戏实战-04-碰撞检测与NPC渲染
2649: 段位计算
Worth more than 100 million! The 86 version of "red boy" refuses to be a Daocheng Xueba. He is already a doctor of the Chinese Academy of Sciences and has 52 companies under his name
Swiperjs custom width
196. 删除重复的电子邮箱
How to use devaxpress WPF to create the first MVVM application in winui?
Use of formdata
"Software testing" packaging resume directly improves the pass rate from these points
Baidu cloud face recognition