What is Web Storage?
Web Storage is a specification that was a part of HTML5 and it also named DOM Storage.
The developers usually only store user and/or session identifiers in cookies, and then use databases to use the rest of the user data.
The limitations of cookies are:
– our search and browsing history can be tracked and our privacy is a concern.
– they have data capacity limitations.
– the limit of cookies in web browsers is about 4 KB per cookie.
There are two types of Web Storage objects: sessionStorage and localStorage.
sessionStorage – our data is accessible to any page from the same site opened in that window.
localStorage – our data spans multiple windows and lasts beyond the current session.
Where Web Storage is used?
You can store the data online to-do stuff.
Also, images can be stored in strings using Base64 encoding.
1 2 3 4 5 | <script type="text/javascript" language="javascript">// <![CDATA[ function supportsLocalStorage() { return ('localStorage' in window) && window['localStorage'] !== null; } if(supportsLocalStorage()) { // Web Storage invocation here alert('Working with support Web Storage'); } else { alert('Your browser does not support Web Storage'); } // ]]></script> |
The output is shown in the next image.
With Google Chrome Browser, you can use three types of storage: Temporary, Persistent, Unlimited.
But, this HTML5 simple feature which is implemented in all the modern browsers local storage.
Using Web Storage is really not more secure than cookies.