-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[html] 第103天 请描述一下cookies、sessionStorage和localStorage的区别? #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
cookie : 是网站为了对用户身份做标识而存储在本地的数据。
localStorage:是HTML5新增的,不会将数据自动发送到服务器,仅存储在本地,并且会永久存储,除非用户主动删除,不然不会过期或者自动清除。 sessionStorage:大部分类同localStorage 除了生命周期持续到当前窗口关闭 后两者在不同浏览器的最大大小不同,因此一般以5M为上限较为安全。 |
参考文章: MDN Cookie |
Cookies网站为了对用户身份做标识而存储在本地的数据。在同源的http请求中会被一同发送,因此会占用网络带宽。最大大小4KB。以前每个域名支持20个,新版本的增加到50个。生命周期为设置的过期时间,若不设置则到关闭浏览器为止。 localStorageHTML5新增的,不会将数据自动发送到服务器,仅存储在本地,并且会永久存储,除非用户主动删除,不然不会过期或者自动清除。 sessionStorage有效期限为一次session会话(即一个tab页从打开到关闭之间的时间段)。 webStorage在不同浏览器的最大大小不同,因此一般以5M为上限较为安全。 |
|
Cookie:保存在浏览器端,若不设置过期时间,会随浏览器关闭而销毁,若设置过期时间,则直到过期时间结束才销毁,只能保存字符串类型,单个cookie不超过4k,http请求时数据会自动传递到服务器上 |
第103天 请描述一下cookies、sessionStorage和localStorage的区别?
#210
The text was updated successfully, but these errors were encountered: