Loading…

Web Storage Playground: localStorage, sessionStorage & Cookies

This playground lets you practise the three simplest ways a website stores data in the browser: cookies, localStorage and sessionStorage. You type simple commands, and they run against the real browser APIs.

Trying the same command on all three is the fastest way to see how they differ — how long the data lasts, and where it can be read.

Things to try

  • Save a value with LOCAL SET and read it back with LOCAL GET.
  • Store a JSON object, such as a shopping cart, in localStorage.
  • Save a SESSION value, then think about what happens when the tab closes.
  • Set and read a COOKIE, then DELETE it.
  • Use CLEAR to empty one type of storage at a time.

How it works

Write one command per line: a target (COOKIE, LOCAL or SESSION), an action (SET, GET, DELETE or CLEAR), then a key and value. Lines starting with # are comments.

The commands call the real document.cookie, localStorage and sessionStorage APIs. Every key is given a special prefix, so the playground never reads or changes this site's own cookies or stored data.

Frequently asked questions

What is the difference between localStorage and sessionStorage?

localStorage keeps data until it is deleted, even after you close the browser. sessionStorage keeps data only for the current tab, and it is cleared when that tab is closed.

How are cookies different from localStorage?

Cookies are sent to the server with every request to that site, and they can have an expiry date. localStorage stays in the browser and is never sent automatically.

Will this change BizTechLab's own cookies?

No. Every key the playground uses has its own prefix, so it only touches its own practice data.