Skip to main content

setItem

setItem(key: string,value: string,storage: undefined | null | string,crypt: boolean,ttl: number,path: string): Promise<void>

Add a key/value in the specified storage

Properties

(Mandatory properties are in bold)
PropertiesTypeDescription
keystring: key of the item
storageundefined | null | string: localStorage, sessionStorage or cookie
valuestring: value of the item
Additional properties for advanced use cases
PropertiesTypeDescription
cryptboolean: encrypt the value (only if cookie). Defaults to true
pathstring: scope of the cookie. Defaults to /
ttlnumber: time to live of the cookie (in seconds). If null, the cookie is removed when the browser is closed