Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære 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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 1

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

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

Sveip for å vise menyen

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 1
some-alt