当前位置:网站首页>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:在所有的同源的窗口下可以共享的
边栏推荐
- Mean Consistency Tracking of Time-Varying Reference Inputs for Multi-Agent Systems with Communication Delays
- 链上治理为何如此重要,波卡Gov 2.0又会如何引领链上治理的发展?
- Play NFT summer: this collection of tools is worth collecting
- What does the errorPage attribute of the JSP page directive do?
- Industrial control network intrusion detection based on automatic optimization of hyperparameters
- CVPR 2022 | SharpContour:一种基于轮廓变形 实现高效准确实例分割的边缘细化方法
- MLX90640 红外热成像仪测温传感器模块开发笔记(十) 成果展示-红眼睛相机
- BGP 第一次实验
- 磁盘与文件系统管理
- 06-SDRAM : SDRAM control module
猜你喜欢

Automatic conversion of Oracle-style implicit joins to ANSI JOINs using jOOQ

Disk and file system management

冒泡排序函数封装

CVPR 2022 | SharpContour:一种基于轮廓变形 实现高效准确实例分割的边缘细化方法

Short video SEO search operation customer acquisition system function introduction

DFS详解

632. 最小区间

An overview of the most useful DeFi tools

面试:简单介绍你参与的一个项目

Knowing the inorder traversal of the array and the preorder traversal of the array, return the postorder history array
随机推荐
基于超参数自动寻优的工控网络入侵检测
nodeJs--各种路径
uni-app project summary
Grid false data injection attacks detection based on coding strategy
Task execution control in Ansible
当奈飞的NFT忘记了Web2的业务安全
A simple file transfer tools
Arduino Basic Syntax
Industrial control network intrusion detection based on automatic optimization of hyperparameters
链上治理为何如此重要,波卡Gov 2.0又会如何引领链上治理的发展?
How to use the go language standard library fmt package
Cyber-Physical System State Estimation and Sensor Attack Detection
Statement执行update语句
【21天学习挑战赛】顺序查找和二分查找的小总结
众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散
AXI4协议介绍
Short video SEO search operation customer acquisition system function introduction
PHP to read data from TXT file
JSP out.print()和out.write()方法的不同之处
面试:简单介绍你参与的一个项目