HTML5 Storage / Web Storage
HTML5 Storage/ Web Storage often refer as “Local Storage” but what actually is HTML5 storage ?
Simple answer is, a way of storing key/value pairs locally within the browser, so even if you close your browser and restart or refresh, the data will persists, but wait!! cookies also do the same so is this HTML5 storage means cookies??
Actually This HTML5 web Storage spec is different from cookies, cookies can be accessed from the server side but key/value pairs of HTML5 sotrage is only accessible from the client side.
HTML5 storage is implemented natively in Major web browsers. But there are few of browsers do not support this spec. let’s see what browsers has support for this spec.
According to the spec Web storage only support string key-value mapping, so to store a data structure you might need to serialize it. Local storage is very much useful if you are building html5 based mobile application targeting multiple platforms.
Here is a very basic example.
StoringÂ
localStorage.setItem("key","value");
Retrieving
var value = localStorage.getItem("key");
This example shows a good way of manipulating it.
TEST