Celebrating 80th Independence Day of India• Jai Hind •Bharat Mata Ki Jai• Jai Hind •Long Live India• Jai Hind •Jai Hind• Jai Hind •

Browser Session Storage

Ashutosh Anand Tiwari
By Ashutosh Anand TiwariPublished Feb 3, 2025 · 2 min read
Browser Session Storage

Session storage is similar to local storage with some basic differences, and it retains data even after a reload.

image.png

Similarly, there are some methods we can use to perform actions and take advantage of them.

sessionStorage.setItem('name', 'heyahsu');
sessionStorage.getItem('name');
sessionStorage.removeItem('name');
sessionStorage.clear();

It has the same 5MB data limit as local storage and is synchronous.

Just remember: It gets cleared when the browser session ends, such as when you close a tab or window. That’s the key difference from local storage.

Structurally, it uses serialized data for storage.

Important: If you switch tabs within the same domain, you won’t get the stored data. However, if you reload the same tab, the data remains. If you duplicate the tab, session storage initializes as a fresh state for that tab and does not sync with the original.

Be mindful of what to store and what not to. Avoid storing sensitive data.

Session storage is best for temporary data related to the current session.

Avoid storing large datasets, asynchronous operations (since it’s synchronous), or data that needs to persist long-term.

Continue Exploring

Profile

Ashutosh Anand Tiwari

Follow

Writer & curator of this digital garden — open notes for learners worldwide.

🌱 Planted and watering by :

🙏 धन्यवाद ! 🙏

tiranga
Request a Topic

Want me to write notes on a course?

Tell me the course, book, or research topic you want covered. If it helps learners, I'll consider adding structured digital notes for it in the garden.

Collaborate

Have a notes collection to feature here?

Do you have open notes you want featured in this digital garden? Let me know — we can collaborate and publish them for learners worldwide.