4. Differences between cookies, sessionStorage, and localStory

Differences between cookies, sessionStorage, and localStory

cookie, sessionSttorage, localStoryare 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325809438&siteId=291194637