DOM Storage

From RuntimeWiki

Jump to: navigation, search

Cookies have limitations, both in terms of the maximum size of the data you can store in a cookie and how it can be used. So that developers can have a more powerful, yet still simple feature, to do some of the things that are impossible or difficult with cookies, the HTML5 effort defines two new features:

  • sessionStorage: This feature allows storage of large amounts of domain-specific data whose lifespan is limited to the lifetime of a particular tab within the web browser. Once the top-level tab is closed, the sessionStorage area for that tab is destroyed by the browser.
  • localStorage: This feature is designed for storage that spans multiple windows, and lasts beyond the current session.

In both cases, using the APIs is simple:

// Save a value
sessionStorage[ 'name' ] = "John";
// Display a value
alert( sessionStorage[ 'name' ] );
=> 'John'

The W3C spec for localStorage and sessionStorage is at:

Here are some Web pages that talk about the feature:

This feature is at least partially implemented in Firefox2/3, Safari4 and IE8, which apparently means that Chrome and Opera haven't delivered this feature yet.

Comments on this feature request

IBM feedback: important feature for future

One of IBM's product teams says this would be important to have in the long-term, but are not critical right away.

Personal tools