HTML5 – New Feature – Storage Tables
HTML5 is introducing a new feature called “Storage Tables”. With “Storage Tables” can be described as a simple database in the browser. This allows you to store and retrieve a value even when the user has closed his browser and reopened it.
Like session HTML storage is in server and it is more useful because it doesn’t get sent to the server (less overhead), and because the fields can contain more information than a cookie.
Currently, although in theory there’s little difference with cookies, HTML5 Storage is more useful because it doesn’t get sent to the server (less overhead), and because the fields can contain more information than a cookie (this feature is untested, BTW). These two advantages are clearest when you want to set a lot of values; for instance for a preference menu.
So what is the difference between localStorage and sessionStorage
Basically sessionStorage sets fields on the browser window. When the window is closed, the session fields are lost, even if the site remains open in another window.
localStorage sets fields on the domain. Even when you close the browser, reopen it, and go back to the site, it remembers all fields in localStorage. The interesting part is that if you change a localStorage field this event fires in all windows that contain a page of your site.
Essentially, that means that the entire sessionStorage is cleared when the user closes the browser window, while localStorage will remain available forever.
PPK has written an article about this. You can find it here: http://www.quirksmode.org/blog/archives/2009/06/html5_storage_t.html
.
Filed under: HTML