Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Using sessionStorage | Persisting Data with Web Storage
Working with JSON and Local Storage in JavaScript

bookUsing sessionStorage

index.js

index.js

copy

When you use sessionStorage, your data is only available for the duration of the page session. This means that as long as you keep the same browser tab or window open, you can store and retrieve values just like you do with localStorage. However, once you close the tab or window, all data saved with sessionStorage is automatically deleted. This makes it ideal for situations where you need temporary storage that should not persist beyond the user's current session. For example, you might use sessionStorage to keep track of a user's progress in a multi-step form, store temporary preferences, or save state that only matters while the user is actively interacting with a specific tab. Unlike localStorage, which keeps data even after the browser is closed and is shared across tabs from the same origin, sessionStorage is isolated to a single tab or window. This ensures that data stored in one session does not leak into another, giving you more control over the lifespan and scope of your data.

1. When does data in sessionStorage get deleted?

2. Which is true about sessionStorage?

question mark

When does data in sessionStorage get deleted?

Select the correct answer

question mark

Which is true about sessionStorage?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 1

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you give examples of when to use sessionStorage versus localStorage?

How do I use sessionStorage in JavaScript?

What are the limitations of sessionStorage?

Awesome!

Completion rate improved to 7.69

bookUsing sessionStorage

Glissez pour afficher le menu

index.js

index.js

copy

When you use sessionStorage, your data is only available for the duration of the page session. This means that as long as you keep the same browser tab or window open, you can store and retrieve values just like you do with localStorage. However, once you close the tab or window, all data saved with sessionStorage is automatically deleted. This makes it ideal for situations where you need temporary storage that should not persist beyond the user's current session. For example, you might use sessionStorage to keep track of a user's progress in a multi-step form, store temporary preferences, or save state that only matters while the user is actively interacting with a specific tab. Unlike localStorage, which keeps data even after the browser is closed and is shared across tabs from the same origin, sessionStorage is isolated to a single tab or window. This ensures that data stored in one session does not leak into another, giving you more control over the lifespan and scope of your data.

1. When does data in sessionStorage get deleted?

2. Which is true about sessionStorage?

question mark

When does data in sessionStorage get deleted?

Select the correct answer

question mark

Which is true about sessionStorage?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 1
some-alt