Local storage
Read or change the current page's localStorage or sessionStorage.
Only in
WarpX Browser
Many sites keep a sign-in, a setting or a cart in the page's storage rather than in cookies. Local storage reads one value or all of them, sets a value, removes one or clears it all, for the site of the page the workflow is on. Together with Cookie it is how you look at or move a session.
Settings
- Description
A note shown on the block in the canvas.
ExampleRead signed-in user- localStorage / sessionStorage
The two choices at the top. localStorage is kept by the profile for the site until it is cleared. sessionStorage belongs to the one tab and is gone when it closes.
ExamplelocalStorage- Action
Get a value, Get everything, Set a value, Remove a value or Clear all.
ExampleGet a value- Keywhen Action is Get a value, Set a value or Remove a value
The name of the value. It can hold references such as
{{variables.storageKey}}.Exampleauth- Valuewhen Action is Set a value
What to store. Storage only holds text, so a reference to a list or an object is written as JSON.
Example{"lang":"en","theme":"dark"}- Assign to variablewhen Action is Get a value or Get everything
Store what was read in a variable.
ExampleChecked- Variable namewhen Assign to variable is ticked
The variable that receives it.
Exampleauth
Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.
What it hands on
Get a value gives the value, parsed when it is JSON, so {{variables.auth.userId}} reaches inside it; a key that is not there gives null. Get everything gives an object of every key and its text. Both go to the variable and on as {{prevBlockData}}. The other actions store nothing.
Example: Read the signed-in user's id from localStorage
- Start
- Open URL
- Local storage
- Insert data
- Add an Open URL block with
https://app.example.com/dashboard, so the page belongs to the site whose storage you want. - Add a Local storage block. Keep localStorage, set Action to Get a value and Key to
auth. - Tick Assign to variable and name it
auth. - Add an Insert data block with a Table row for the column
user_idand the value{{variables.auth.userId}}.
Good to know
- It works on the storage of the page the tab is showing, for that page's site only. Open the site first; a blank tab has no storage to read.
- It reads the top page, not iframes inside it.
- Get everything does not parse the values: each is the text the site stored.
- Get a value, Set a value and Remove a value with an empty Key fail with "No key".
- Many sites read their storage only when the page loads. After Set a value, reload the page with Reload tab for the site to notice.
See also
- Cookie — Reads, sets or removes cookies in the profile's browser.
- Reload tab — Reloads the page in the tab the workflow is using and waits for it to load.
- Insert data — Set variables and add values to the workflow's table, several at once.