Local Storage Vs Session storage

Ashik Mahmud
2 min readSep 7, 2020

--

Storage means where we can store anything. In Programming language, we can store data. Here in our article we will learn what is Local Storage and what is Session storage.

Loacl storage vs Session storage

First we will know about Local Storage. Local storage depends on browser compatibility. Now days, all browsers have varying capacity level for localStorage.

Browser Compatibility

So, localStorage is that where our browser can save data. What’s interesting about localStorage is that the data survives a page refresh and even a full browser restart. Local storage objects provide same methods and properties:

· setItem(key, value) — store key/value pair.

· getItem(key) — get the value by key.

· removeItem(key) — remove the key with its value.

· clear() — delete everything.

· key(index) — get the key on a given position.

· length — the number of stored items.

Local Storage File Search

And now we will know about Session Storage. Session Storage is a temporary storage. sessionStorage is that the data survives a page refresh but cannot survive full browser restart or close a tab. In Example, you will buy a ticket and go to stadium for enjoy the match. But in the middle of the match you leave the stadium. A few moments later , will you again enter into the stadium? No, you don’t. Local storage objects provide same methods and properties:

· setItem(key, value) — store key/value pair.

· getItem(key) — get the value by key.

· removeItem(key) — remove the key with its value.

· clear() — delete everything.

· key(index) — get the key on a given position.

· length — the number of stored items.

Session storage File Search

--

--

Ashik Mahmud
Ashik Mahmud

No responses yet