putPref

Preferences

Sets the value of the specified preference. The preferences are not persisted until you explicitly call $m.savePref(). By default, preferences are committed during onPause event is fired on the page.

$m.putPref("user_id", "guest");

Syntax

        $m.putPref(key, value, [global])

Parameters

key

string (required)

Key of the preference to be stored.

value

strng/boolean/number/object (required)

Value of the property to be stored.

global

boolean (optional)

True, if the preference is to be stored as a global preference. Default value is false.

Remarks

Preferences can be used to store app data that needs to persist across app restarts. By default, the preferences stored in a page are accessible in other pages provided if the pages belong to the same pack. In order to share preferences across packs, use the global parameter.