HTML Session Storage

Last Updated:

HTML Session Storage

The HTML Session Storage allows you to access and save data (key/value pairs) in a web browser.

Note: The properties of Session Storage as follows:

  • Unlike Local Storage, the data stored in Session Storage is cleared when the page session ends.
  • Closing a tab/window ends the session and clears objects in Session Storage.
  • The keys and values are always strings.

How to view Session Storage?

Follow the below steps to view your data stored in the Session Storage:

  1. Go to Developer Tools or Press F12 or Press Ctrl + Shift + i.
  2. Switch to Application Tab on the top navigation bar.
  3. On the left side menu you will find the Session Storage.

Note: If you couldn't find your recent changes in the Session Storage, close and reopen the developer tools to see the changes.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <div id="point"></div> <script> var x = document.getElementById("point"); function UserVisit(){ if(typeof(Storage) !== "undefined"){ if(sessionStorage.visitCount) sessionStorage.visitCount = Number(sessionStorage.visitCount) + 1; else sessionStorage.visitCount = 1; x.innerHTML = "You have visited this page " + sessionStorage.visitCount + " time(s) in this Session."; } else{ x.innerHTML = "Sorry, your browser does not support web storage..."; } } UserVisit(); </script> </body> </html>

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
session storageYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author