VOOZH about

URL: https://www.geeksforgeeks.org/javascript/how-to-clear-session-storage-data-with-specified-session-storage-item/

⇱ How to Clear Session Storage Data with Specified Session Storage Item? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Clear Session Storage Data with Specified Session Storage Item?

Last Updated : 23 Jul, 2025

JavaScript sessionStorage is a web storage technique that allows you to store data in a web browser. You can manually set and retrieve the values from it using some methods. The sessionStorage stores the data for a short amount of time until the browser tab or window gets closed. We will learn how to clear the session storage of a browser using JavaScript by getting the specified session storage item.

Using Window sessionStorage( ) property

We can achieve this by using theWindow sessionStorage( )property. The Window sessionStorage() property saves key/value pairs in a web browser. It stores the key/value pairs in a browser for only one session and the data expires as soon as a new session is loaded.

Syntax

window.sessionStorage

We can clear the session storage by using the clear() method.

sessionStorage.clear()

Example: This example we demonstrates how to manage session storage. It allows users to display, check if the session storage is empty, and clear items. Initial items are set in session storage for demonstration.

Output:

Comment