variable sessionStorage
Deno's sessionStorage
API operates similarly to the localStorage
API,
but it is intended for storing data temporarily for the duration of a session.
Data stored in sessionStorage is cleared when the application session or
process ends. This makes it suitable for temporary data that you do not need
to persist across user sessions.
- Key-Value Storage: Stores data as key-value pairs.
- Session-Based: Data is only available for the duration of the page session.
- Synchronous API: Operations are performed synchronously.
sessionStorage
is similar to localStorage
, and shares the same API
methods, visible in the Storage
type.
For more information, see the reference guide for Web Storage
Example 1
Example 1
// Set a value in sessionStorage
sessionStorage.setItem("key", "value");
// Get a value from sessionStorage
const value = sessionStorage.getItem("key");
console.log(value); // Output: "value"
// Remove a value from sessionStorage
sessionStorage.removeItem("key");
// Clear all the values from sessionStorage
sessionStorage.clear();