4. Differences between cookies, sessionStorage, and localStory
Others
2022-04-27 19:38:40
views: 0
Differences between cookies, sessionStorage, and localStory
cookie
, sessionSttorage
, localStory
are storage mechanisms that store key-value pairs on the client side, and can only store values as strings
|
cookie |
localStorage |
sessionStorage |
who is initialized by |
Client or server, the server can use the Set-Cookie request header. |
client |
client |
Expiration |
manual setting |
never expires |
When the current page is closed |
Whether to persist in the current browser session (browser sessions) |
Depends on whether an expiration time is set |
Yes |
no |
Is it associated with a domain name |
Yes |
no |
no |
whether to send to the server with every HTTP request |
Yes, Cookies will be automatically sent to the server through the Cookie request header |
no |
no |
Capacity (per domain name) |
4kb |
5MB |
5MB |
access permission |
Origin http://43.154.161.224:23101/article/api/json?id=325809438&siteId=291194637