Skip to main content

Function: setItem

setItem(key, value, storage, crypt?, ttl?, path?): Promise<void>

Add a key/value in the specified storage

Parameters

NameTypeDefault valueDescription
keystringundefined: key of the item
valuestringundefined: value of the item
storagestring | null | undefinedundefined: localStorage, sessionStorage or cookie
cryptbooleantrue: encrypt the value (only if cookie). Defaults to true
ttl?numberundefined: time to live of the cookie (in seconds). If null, the cookie is removed when the browser is closed
pathstring'/': scope of the cookie. Defaults to /

Returns

Promise<void>

Defined in

onekijs/packages/onekijs-framework/src/utils/storage.ts:147