The localstorage method works like cookies, saving information for an entire site (origin) with no time limit.
Example
<html>
<body>
<script type="text/javascript">
localStorage.lastname = "Aggarwal";
document.write("Last name: " + localStorage.lastname);
</script>
</body>
</html>
Output
Last name: Aggarwal
HTML 5 SessionStorage Method
The SessionStorage, will store information for each origin but keep it isolated between windows or tabs and delete the data when the user closes the browser window.
Example
<html>
<body>
<script type="text/javascript">
sessionStorage.lastname = "Aggarwal";
document.write(sessionStorage.lastname);
</script>
</body>
</html>
Output
Aggarwal
Summary