当前位置:网站首页>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:在所有的同源的窗口下可以共享的
边栏推荐
- 微软电脑管家V2.1公测版正式发布
- JSP Taglib指令具有什么功能呢?
- Short video seo search optimization main content
- 什么是低代码(Low-Code)?低代码适用于哪些场景?
- 【CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!)(A~D)】
- TCL: Pin Constraints Using the tcl Scripting Language in Quartus
- The Statement update Statement execution
- JSP request对象功能详解说明
- Knowing the inorder traversal of the array and the preorder traversal of the array, return the postorder history array
- When Netflix's NFTs Forget Web2 Business Security
猜你喜欢

路由策略

Graphical LeetCode - 1161. Maximum Sum of In-Layer Elements (Difficulty: Moderate)

uni-app project summary
![[21-Day Learning Challenge] A small summary of sequential search and binary search](/img/81/7339a33de3b9e3aec0474a15825a53.png)
[21-Day Learning Challenge] A small summary of sequential search and binary search

String splitting function strtok exercise

An interesting project--Folder comparison tool (1)

go笔记——锁

Using the "stack" fast computing -- reverse polish expression

nodeJs--各种路径

Redis - message publish and subscribe
随机推荐
How does JSP use request to get the real IP of the current visitor?
go语言标准库fmt包怎么使用
uni-app项目总结
An interesting project--Folder comparison tool (1)
What does the errorPage attribute of the JSP page directive do?
Collection of NFT tools
使用jOOQ将Oracle风格的隐式连接自动转换为ANSI JOIN
Disk and file system management
含外部储能的电力系统暂态稳定分布式控制
TCL: Pin Constraints Using the tcl Scripting Language in Quartus
Play NFT summer: this collection of tools is worth collecting
PHP to read data from TXT file
Mean Consistency Tracking of Time-Varying Reference Inputs for Multi-Agent Systems with Communication Delays
C language character and string function summary (2)
What is the function of the JSP out.println() method?
ROS dynamic parameters
Redis的集群模式
MLX90640 红外热成像仪测温传感器模块开发笔记(十) 成果展示-红眼睛相机
[Solution] Emqx startup under win10 reports Unable to load emulator DLL, node.db_role = EMQX_NODE__DB_ROLE = core
When Netflix's NFTs Forget Web2 Business Security