12. What's the difference between local storage and session storage?

sessionStorage i localStorage are data containers, provided to application by browser. It holds data in text format as a key/value pairs. It's size depends on browser.

They share same API:

  • setItem(key, value) - ustawia wartość value pod kluczem key
  • getItem(key) - zwraca wartość spod klucza key
  • removeItem(key) - usuwa wartość spod klucza key
  • clear() - czyści pamięć.

Differences:

Session Storage:

  • Cleared on closing tab/browser
  • About 5MB memory
  • Is not shared between browser's tabs, even if they are under same domain

Local Storage:

  • It's not cleared automatically - it has to be cleared manually in devtools, in browser's settings or from code
  • About 5-10MB memory
  • Browser's tab share it if they are under same domain
Struggling to find common date to meet with your friends? Try our new tool commondate.xyz
devFlipCards 2025

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.

Struggling to find common date to meet with your friends? Try our new tool
commondate.xyz