January 10, 2017 - Søren Alsbjerg Hørup

Persisting stuff between sessions is really easy using using the Window.localStorage API provided by most browsers today.

localStorage is a key/value store, where one can write and read keyvalues. Setting a value is super easy using setItem:

localStorage.setItem('key', 'value');

Getting back an item is done using getItem:


Persistence is per domain (and subdomain) which is really nice since one do not have to implement any annoying cookie notifications.