## SessionStorage API

### Methods

- `hasItem(key: string): boolean`
  Check if storage item exists
  Params:
    - `key` (string, required)
      Entry key
      Examples: `'userId'`
  Returns: `boolean`
    Does the item exist or not?
- `getLength(): number`
  Get storage number of entries
  Returns: `number`
    Number of entries
- `getItem(key: string): number | boolean | Date | RegExp | object | any[] | string`
  Get a storage item value
  Params:
    - `key` (string, required)
      Entry key
      Examples: `'userId'`
  Returns: `number | boolean | Date | RegExp | object | any[] | string`
    Storage item value; null for a missing item
    Examples: `'john12'`, `702`
- `getIndex(index: number): number | boolean | Date | RegExp | object | any[] | string`
  Get the storage item value at specific index
  Params:
    - `index` (number, required)
      Entry index
  Returns: `number | boolean | Date | RegExp | object | any[] | string`
    Storage item value at that index; null past the end
- `getKey(index: number): string`
  Get the storage key at specific index
  Params:
    - `index` (number, required)
      Entry index
  Returns: `string`
    Storage key; null past the end
    Examples: `'userId'`
- `getAll(): object`
  Retrieve all items in storage
  Returns: `object`
    Object syntax: item name as Object key and its value
    Examples:
      - `{ userId: 'rstoenescu', timesLoggedIn: 14 }`
- `getAllKeys(): any[]`
  Retrieve all keys in storage
  Returns: `any[]`
    Storage keys (Array of Strings)
    Examples:
      - `['userId', 'password']`
- `setItem(key: string, value: number | boolean | Date | RegExp | Function | object | any[] | string): void`
  Set item in storage; a null or undefined value removes the item (as removeItem() does)
  Params:
    - `key` (string, required)
      Entry key
      Examples: `'userId'`
    - `value` (number | boolean | Date | RegExp | Function | object | any[] | string, required)
      Entry value; a Function is stored as its source
      Function signature: `(...params: any) => any`
      Examples: `'john12'`
      Params:
        - `...params` (any, optional)
      Returns: `any`
- `removeItem(key: string): void`
  Remove a storage item
  Params:
    - `key` (string, required)
      Storage key
      Examples: `'userId'`
- `clear(): void`
  Remove everything from the storage
- `isEmpty(): boolean`
  Determine if storage has any items
  Returns: `boolean`
    Tells if storage is empty or not
- `useStorage(key: string, options?: object): object`
  Get a Vue ref bound to a storage item: it reads the item value (the default, or null, while missing), assigning it persists the value (null removes the item, or resets it to the default) and a nested change of an object or Array value gets persisted too. It follows the changes made through the other methods, through other refs of the same item and from another tab/window of the same origin. It is released together with the calling scope (a component, a Pinia store, an effectScope()); outside of one, call its stop() method when done
  Params:
    - `key` (string, required)
      Entry key
      Examples: `'theme'`
    - `options` (object, optional)
      Options
      Object shape:
        - `default` (Function, optional)
          Returns the value the ref reads while the item is missing; called when the ref is created and each time the ref takes the default again (a null assignment, a removal), so that an object or Array default is a fresh one every time; the value gets stored when the ref attaches to a missing item and again whenever the item is removed
          Function signature: `() => number | boolean | Date | RegExp | object | any[] | string`
          Examples: `() => 'light'`, `() => ({ notifications: true })`
          Returns: `number | boolean | Date | RegExp | object | any[] | string`
            The default value
        - `deep` (boolean, optional), default `true`
          Hand out an object or Array value reactive, so that a nested change gets tracked and persisted; set it to false for a large value that you only ever assign as a whole
        - `disabled` (boolean | object | Function, optional)
          While true the ref is detached from the storage (a plain in-memory ref); once false again it attaches like a new ref: the stored value wins if the item exists, otherwise the current value gets stored
          Examples: `true`, `() => consent.value !== true`
        - `onError` (Function, optional)
          Called when the storage cannot be written (quota exceeded, private browsing) or a stored value cannot be decoded (when the ref attaches, or when another tab stored it); without it the error is thrown
          Function signature: `(err?: Error) => void`
          Examples: `err => { Notify.create(err.message) }`
          Params:
            - `err` (Error, optional)
              The error
  Returns: `object`
    A Vue ref with an extra stop() method that detaches it from the storage

### Vue Injection

Accessible via `$q.sessionStorage` (e.g., `this.$q.sessionStorage` in Options API or `useQuasar().sessionStorage` in Composition API).

