Currently Browsing: W3C

What is the DOM Storage?

W3C DOM Storage The DOM Storage (pronounced Dam Storage), also called the Web Storage, is the functional evolution of the existing cookie and you can bet that will be a common standard that will change many habits.
Currently being standardized, is emerging with HTML 5 and is now supported (in part) from Internet Explorer 8, Firefox and Safari 2 +.

Developers can use this technology to store data temporarily for a session or permanently for a domain, clients are compatible.

The data are stored with a structure to associative array, ie a set of pairs of names and values.

It is not in any way except a redundant use of cookies and Web Storage.

Here is a sample counter displays made with DOM Storage (tested and running on Internet Explorer 8, Firefox 3.5 and Safari 4):

You see this page <p> <span id="contatore"> an unknown number </ span> times. </ P>
<script>
/ / Create an object window.localStorage
/ / Which stores data permanently for a domain
var data = window.localStorage;

/ / If the variable does not exist numeroVisualizzazioni initialized to 0
if (! dati.numeroVisualizzazioni) dati.numeroVisualizzazioni = 0;

/ / Add 1 to counter current
dati.numeroVisualizzazioni = parseInt (dati.numeroVisualizzazioni) + 1;

/ / Update the content of span
document.getElementById ('counter'). innerHTML = dati.numeroVisualizzazioni;
</ Script>

Compared to cookies, DOM Storage provides more functionality and development opportunities, which we see:

  1. Sun Storage allows constant monitoring of the pairs of stored data even from different windows, bound to the single window or tab. Therefore provides total control in some situations, for example avoids problems due to operations carried out on multiple browser windows.
    The example shown by the W3C to explain the usefulness of this control is that a user wishing to purchase tickets. The transaction with multiple windows open on the same site at the end from one window to another and doing a bit 'of confusion is found stored in the "cart", managed by the cookie, more tickets than desired. Likely to combine a mess.
  2. Cookies store than 4KB of data, DOM Storage stores well for up to 5MB (10MB for Internet Explorer 8);
  3. The DOM data storage does not have an expiration setting and may be permanent, unlike the cookie. The control is left in the hands of users;
  4. The DOM data are not transmitted to the server for each web request, thus avoiding unnecessary transmission of information;
  5. Sun Storage can work offline, storing everything on disk and then once you have found the event network connection request to store the data on the server. This makes web applications even in the absence of functional connectivity;

References for further information:

Surely there will be security issues that emerge with widespread use. But the potential for development of web applications will be very interesting.

What do you think?