Class: session

LuCI. session

The session class provides various session related functionality.

new LuCI.session()

Methods

getID(){string}

Retrieve the current session ID.

Returns:
Type Description
string Returns the current session ID.

getLocalData(key){*}

Retrieve data from the local session storage.

Name Type Description
key string optional

The key to retrieve from the session data store. If omitted, all session data will be returned.

Returns:
Type Description
* Returns the stored session data or null if the given key wasn't found.

getToken(){string|null}

Retrieve the current session token.

Returns:
Type Description
string | null Returns the current session token or null if not logged in.

setLocalData(key, value){boolean}

Set data in the local session storage.

Name Type Description
key string

The key to set in the session data store.

value *

The value to store. It will be internally converted to JSON before being put in the session store.

Returns:
Type Description
boolean Returns true if the data could be stored or false on error.