Serialize a value as JSON and store it in sessionStorage.
sessionStorage
Usage:
import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";setSessionStorage("test", "123");const ret1 = getSessionStorage("test");setLocalStorage("test", "123");const ret2 = getLocalStorage("test");console.log(ret1, ret2);// Wrap the helpers with a project-specific key prefix.const projectName = "mazey";function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);} Copy
import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";setSessionStorage("test", "123");const ret1 = getSessionStorage("test");setLocalStorage("test", "123");const ret2 = getLocalStorage("test");console.log(ret1, ret2);// Wrap the helpers with a project-specific key prefix.const projectName = "mazey";function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);}
Output:
123 123 Copy
123 123
Storage key.
Value to serialize and store.
This function does not return a value.
Serialize a value as JSON and store it in
sessionStorage.Usage:
Output: