Local storage

Local storage may be used to store data specific to an application after the browser is closed. In this page you learn how API front calls are used to manage this data.

Overview

For example, local storage can be used to keep track of authenticated users, if the authentication mechanism is written in Genero. Data stored locally is restricted for reuse to the application URI.

NOTE: Local storage (or web storage) refers to HTML5 Local Storage, which is a browser feature. See HTML5 Local Storage for more information.

The ui.Interface.frontcall API can be used to store key/value pairs locally on the machine where the browser executes. Calls to functions of the localStorage module, such as getItem and setItem, can implement the storage and retrieval of key/value pairs. An example to store a key/value is shown:

CALL ui.Interface.frontCall("localStorage", "setItem", [key,value], [])

Where:

  • key is the name of the local storage key.
  • value is the value to set for the named key.

Return keys stored locally on a front-end

The keys function in the example returns a list of all the current local storage keys defined on the front-end platform. The list of keys is returned as a JSON array of strings in key_list.

CALL ui.Interface.frontCall("localStorage", "keys", [], [key_list] )

For more information on using local storage front calls, see the Local storage front calls topic in the Genero Business Development Language User Guide.