Web storage
Web Storage provides a client-side method for saving session information. Web Storage is a new HTML5 API offering important benefits over traditional cookies. All major browsers support it. Cookie had data-capacity limitations of 4KB per cookie but web storage has a simple API to get and set key/value pairs and the storage depends on the browser settings usually 5 to 10 MB per domain. The data being stored can be accessed using JavaScript. The web storage API provides following methods
Attribute | Detail |
setItem(key,value) | adds a key/value pair to the sessionStorage object. |
getItem(key) | retrieves the value for a given key. |
clear() | removes all key/value pairs for the sessionStorage object. |
removeItem(key) | removes a key/value pair from the sessionStorage object. |
key(n) | retrieves the value for key[n]. |
As implemented in the example below.
<a href=”javascript:;” onClick=”if(sessionStorage && sessionStorage.getItem(‘name’)) { alert(‘Come back soon, ‘ + sessionStorage.getItem(‘name’)); }”>Sign Out</a>
Apply for HTML5 Certification Now!!
http://www.vskills.in/certification/Certified-HTML5-Developer