HTML5 Local Storage और Session Storage

localStorage – data को expire नहीं करता जब तक हम Browser के cookies delete नहीं करते |
sessionStorage – data को browser tab बंद करने पर expire करता है |

localStorage का उदहारण

<!DOCTYPE html>
<html>
<body>

<div id=”show”></div>

<script>
localStorage.setItem(“name”, “vicky”);
document.getElementById(“show”).innerHTML = localStorage.getItem(“name”);

</script>

</body>
</html>

 


sessionStorage का उदहारण

<!DOCTYPE html>
<html>
<body>

<div id=”show”></div>

<script>
sessionStorage.setItem(“name”, “vicky”);
document.getElementById(“show”).innerHTML = sessionStorage.getItem(“name”);

</script>

</body>
</html>

Leave a Reply