HTML and CSS Reference
1.3.6. Web storage
For many years, web applications have used cookies to store small chunks of data in the
client that persist for the session or between multiple sessions. This is the technology un-
derlying web authentication systems—they store on the client a cookie that holds some
form of identifier used to tell the application who's logged in. Cookies present a number of
issues, making them less useful for storing all but the smallest chunks of data.
The first issue is that most browsers limit the size of cookies to 4 kilobytes, and the number
of cookies stored per domain to 20. After reaching these limits, the browser will start dis-
carding older cookies to make way for the newer ones, which means there's no guaran-
are sent in every HTTP request made for the session, adding overhead to each and every
transaction. This might not be an issue if you're using one or two cookies, but what if
you use several? And consider that the cookies will be sent along with every HTTP re-
quest—slowing down every page load and AJAX request your application makes.
tions. It defines two interfaces:
• sessionStorage —Client-side data storage that persists for the length of the
current session only
• localStorage —Client-side data storage that persists for multiple sessions
These APIs expose methods that allow developers to store simple key/value pair data in a
client-side store. The data items stored using these interfaces are accessible only by pages
stores user settings and preferences in local storage.