Difference between revisions of "Bot Playground/Built-in Functions/localStorage.set"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} <onlyinclude>Puts a string value into a persistent storage.</onlyinclude> Also check localStorage.get(). <syntaxhighligh...") |
|||
Line 3: | Line 3: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
− | localStorage.set( | + | localStorage.set(name, value); |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 10: | Line 10: | ||
{{API Variable Group|Input}} | {{API Variable Group|Input}} | ||
− | {{API Variable|name|yes}} the name of the persistent value you would like to | + | {{API Variable|name|yes}} the name of the persistent value you would like to store |
− | + | {{API Variable|value|yes}} the value you want to save. | |
{{API Variable Group|Output}} | {{API Variable Group|Output}} | ||
{{API Return none}} | {{API Return none}} | ||
Line 19: | Line 19: | ||
== Comments == | == Comments == | ||
− | This function works similar to browser JavaScript localStorage. | + | This function works similar to browser JavaScript localStorage.set(). It saves value into a persistent storage. |
localStorage is shared by all scripts of the same bot. Thus, you can set values in one bot script and retrieve it in another script. | localStorage is shared by all scripts of the same bot. Thus, you can set values in one bot script and retrieve it in another script. | ||
+ | |||
+ | Also note that localStorage supports string values only. To save something more complicated, use JSON.stringify(var). | ||
+ | |||
{{NavMenu}} | {{NavMenu}} |
Revision as of 14:56, 6 October 2016
Puts a string value into a persistent storage. Also check localStorage.get().
localStorage.set(name, value);
Reference
This command accepts the following parameters:
Variable | Required | Description
| |
---|---|---|---|
Input: | |||
name | yes | the name of the persistent value you would like to store | |
value | yes | the value you want to save. | |
Output: | |||
result | This function does not return anything |
Comments
This function works similar to browser JavaScript localStorage.set(). It saves value into a persistent storage.
localStorage is shared by all scripts of the same bot. Thus, you can set values in one bot script and retrieve it in another script.
Also note that localStorage supports string values only. To save something more complicated, use JSON.stringify(var).