·

Differences between localStorage, sessionStorage and cookies

Published at 2024-05-14 19:25:04Viewed 405 times
Common article
Please reprint with source link

We can store tokens and user information in localStorage, sessionStorage, or cookies. They are all ways of browser that store data locally. In browser, open the developer mode, and click Application. Then you can view the messages stored in the localStorage, sessionStorage, and cookies on the website.

Developer mode


Here are some differences between LocalStorage, SessionStorage, and Cookies:

  1. Data in LocalStorage have no lifecycle which means it will never expire, and need to be manually deleted. It is merely stored locally in your computer and will not be sent to the backend server. LocalStorage occupies less space.
  2. SessionStorage is similar to LocalStorage, but data in SessionStorage have a lifecycle. In other words, it will expire and be automatically deleted after you close the browser which closes any session. SessionStorage occupies less space.
  3. Cookies also have a lifecycle, and are automatically deleted upon expiration. However, they will be sent to the backend server whenever the browser sends requests. Moreover, cookies occupy much more space.
Comments

There is no comment, let's add the first one.

弦圈热门内容

Get connected with us on social networks! Twitter

©2024 Guangzhou Sinephony Technology Co., Ltd All Rights Reserved