HTML5 Session Storage

  • Stores data for one session
  • The data is deleted when the browser’s window is closed.

<script>
    sessionStorage.variableName = "value";
    alert(sessionStorage.variableName);
    sessionStorage.removeItem("variableName");
    alert(sessionStorage.variableName);
</script>

HTML5 Local Storage

HTML5 Local Storage

Let’s discuss what HTML5 Local Storage is all about.

  • HTML5 Local Storage stores data with no time limit,
  • Data can be accessible at anytime and any windows/tabs (with some conditions like same domain and same browser) even if the browser is restarted.

<script>
    localStorage.variableName = "value";
    alert(localStorage.variableName);
    localStorage.removeItem("variableName");
    alert(localStorage.variableName);
</script>