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

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 1

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

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

Stryg for at vise menuen

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

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 1
some-alt