PP.App.setStorage

Syntax

setStorage(key: String, value: String, local: Boolean);

Parameters

key. Parameter key in the browser storage.

value. Parameter value.

local. It indicates whether browser storage data is saved after the tab closes. If the parameter is true, storage data is saved after closing the browser tab, otherwise the data is stored only for one tab until it closes.

Description

The setStrorage method saves the specified parameter to the browser storage.

Example

Executing the example requires that the Foresight Analytics Platform web application is opened. The scenario specified below must be started in the browser console.

Determine a system custom parameter and save it in the browser local storage, and then delete this parameter:

// Create own parameter
PP.App.setStorage("MyParam", 1, true);
console.log("Value of the MyParam parameter: " + PP.App.getStorage("MyParam", true));
// Now delete this parameter
PP.App.deleteStorage("MyParam", true);
// Try again to get parameter value
var param = PP.App.getStorage();
if (param = "MyParam"){
    console.log("The MyParam parameter was not deleted")
} else {
    console.log("The MyParam parameter was deleted")
};

After executing the example the browser console displays value of custom parameter saved in the browser local storage, and a notification if this parameter has been deleted:

MyParam value: 1
MyParam has been deleted

See also:

PP.App