当前位置:网站首页>JS中localStorage和sessionStorage
JS中localStorage和sessionStorage
2022-08-02 00:14:00 【weixin_46051260】
localStorage:永久存储在本地,适合保存在本地的数据
sessionStorage:会话级的存储,敏感帐号一次登陆
相同点:
1)都是保存在浏览器端
2)不会把数据自动的发送给服务器,仅在本地保存
3)只能存储字符串,可以将对象JSON.stringify()编码之后进行存储
不同点:
1)存储大小限制不同:sessionStorage存储的大小为5M,localStorage存储大小为20M
2)数据有效期不同:
- localStorage:始终有效,窗口关闭或者浏览器关闭,一直保存,持久保存数据
- sessionStorage:仅在当前浏览器窗口关闭前有效,会话级存储
3)作用域不同:
- sessionStorage:在不同浏览器窗口不会进行共享,只有同一个页面中才ok
- localStorage:在所有的同源的窗口下可以共享的
边栏推荐
- JSP内置对象out对象的功能简介说明
- AXI4协议介绍
- 含外部储能的电力系统暂态稳定分布式控制
- Stapler:1 靶机渗透测试-Vulnhub(STAPLER: 1)
- JSP how to obtain the path information in the request object?
- Looking back at 5 recessionary times in history: How might this time be different?
- BGP综合实验 建立对等体、路由反射器、联邦、路由宣告及聚合
- Redis-消息发布订阅
- Play NFT summer: this collection of tools is worth collecting
- PHP to read data from TXT file
猜你喜欢
随机推荐
How to use the go language standard library fmt package
Don't know about SynchronousQueue?So ArrayBlockingQueue and LinkedBlockingQueue don't and don't know?
Arduino Basic Syntax
Are test points the same as test cases?
22. The support vector machine (SVM), gaussian kernel function
NodeJs, all kinds of path
Unknown CMake command "add_action_files"
冒泡排序函数封装
抖音数据接口API-获取用户主页信息-监控直播开启
uni-app project summary
不要用jOOQ串联字符串
An Enhanced Model for Attack Detection of Industrial Cyber-Physical Systems
What is the function of the JSP Taglib directive?
PHP to read data from TXT file
C language character and string function summary (2)
els block deformation
go笔记之——goroutine
Kotlin协程:创建、启动、挂起、恢复
poker question
扑克牌问题









