Web storage
DOM storage is a mechanism for web applications to store data in a web browser. The DOM storage API supports persistent data storage, similar to cookies, as well as window-local storage.
DOM storage is being standardized by the World Wide Web Consortium (W3C) as part of the HTML 5 specification. It is supported by newer Mozilla-based browsers (e.g., Firefox 2+), Internet Explorer 8, and Safari.[1]
Features
DOM storage can be viewed simplistically as an improvement on cookies, providing much greater storage capacity (5MB per domain in Firefox[2], 10MB in Internet Explorer[3]) and better programmatic interfaces. However, it differs from cookies in some key ways.
Local and session storage
DOM storage offers two different storage areas -- local storage and session storage -- which differ in scope and lifetime. Data placed in local storage is per domain (it's available to all scripts from the domain that originally stored the data) and persists after the browser is closed. Session storage is per-page-per-window and is limited to the lifetime of the window. Session storage is intended to allow separate instances of the same Internet application to run in different windows without interfering with each other, a usage case that's not well-supported by cookies.[4]
Client-side interface
Unlikely cookies, which can be accessed by both the server and client side, DOM storage falls exclusively under the purview of client-side scripting. DOM storage data is not transmitted to the server in every HTTP request, and a web server can't directly write to DOM storage.
Storage model
DOM storage currently provides an associative array storage model where the keys and values are both strings. An additional API for accessing structured data, perhaps based on SQL, is being considered by the W3C HTML 5 Working Group.[5]
Nomenclature
The W3C draft for DOM storage is titled "Web Storage", but "DOM storage" is the more commonly used name.[6][7]
The "DOM" in DOM storage doesn't literally refer to the Document Object Model. "The term DOM is used to refer to the API set made available to scripts in Web applications, and does not necessarily imply the existence of an actual Document object..."[8]
Similar technologies
- HTTP cookies
- Local Shared Objects in Adobe Flash
- userData Behavior in Internet Explorer