Local Storage

Contact Us or call 1-877-932-8228
Local Storage

Local Storage

Like cookies, HTML5 local storage offers a mechanism for storing key/value pairs locally, within the client browser, even after you navigate away from the page, close the browser, etc. Unlike cookies, these data are never sent back to the server.

In addition, HTML5 offers session storage - similar to local storage, session storage persists between page requests, but does not persist after the browser is closed.

We use HTML5 web storage to store key/value pairs. Browsers typically limit the amount of client-side storage space allocated to a single domain to 5 megabytes and throw a QUOTA_EXCEEDED_ERR exception if you try to store more than that.

Here are the JavaScript methods and properties for working with web storage:

Web Storage Methods & Properties
Method/Property Description
length Holds the number of key/value pairs
setItem(key,value) Creates or updates a key/value pair
getItem(key) Gets the value of the specified key
key(n) Returns the nth key. Useful for iterating through key/value pairs
removeItem(key) Removes the key/value pair for the given key
clear() Removes all key/value pairs
Next