qns(js): describe different storage methods (#376)

This commit is contained in:
Anisha Jain 2023-05-16 15:40:13 -07:00 committed by GitHub
parent a4bfcf3814
commit 97d21312f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,12 @@
title: Describe the difference between a cookie, `sessionStorage` and `localStorage`.
---
Local storage is useful for storing data that the user will need to access later, such as offline data, because it stores the data in the browser and the system. This data will persist even if the user closes and reopens the browser and is accessible by other sites.
Session storage is a great way to improve the performance of your web applications. It stores data locally on the browser but is specific to (and only accessible by) the respective site/browser tab and is only available while the user is on the site/tab. This is a more secure storage method due to the restrictive access and promotes better site performance due to reduced data transfer between server and client.
Cookies are a good choice for storing data that should not be persisted for a long time, such as session IDs. Cookies allow you to set an expiry time at which point it would be deleted. Cookies can only be smaller sized data compared to the other two storage methods.
## Similarities
Cookies, `localStorage`, and `sessionStorage`, are all: