Cookie
Reads, sets or removes cookies in the profile's browser.
Only in
WarpX Browser
Cookie works on the profile's own cookie store, the same one its pages use. You can read one cookie or many into a variable or the table, set a cookie before a page loads, or remove cookies to sign out or reset a site. It works on the whole browser, so no page needs to be open.
Settings
- Get cookies / Set cookie / Remove cookies
The unlabelled list at the top. It chooses what the block does: Get cookies, Set cookie or Remove cookies.
ExampleGet cookies- Get all cookieswhen Get cookies
Off: the block reads the first cookie that matches URL and Name. On: it reads every cookie that matches all the filters you fill in, as a list.
ExampleUnchecked- Use JSON format
Replaces the fields below with a JSON editor, where you write the cookie details yourself. For Set cookie the keys are
name,value,url,domain,path,secure,httpOnly,sameSiteandexpirationDate, the expiry date as a Unix time in seconds. For example:{"name": "session_id", "value": "abc123", "url": "https://shop.example.com/", "expirationDate": 1798761600}.ExampleUnchecked- URLwhen Use JSON format is off
The site the cookie belongs to. When getting or removing, only cookies that would be sent to this address match. Leave it empty to match cookies from every site.
Examplehttps://shop.example.com/- Namewhen Use JSON format is off
The cookie's name. Fill it in for Get cookies without Get all cookies, where the label reads Name. For the other modes the label reads Name (optional), but setting a cookie still needs a name.
Examplesession_id- Value (optional)when Set cookie, with Use JSON format off
The cookie's value. Leave it empty to set a cookie with no value.
Exampleabc123- Path (optional)when Use JSON format is off
The cookie's path. For Set cookie, empty means
/with Domain (optional), or the folder of the URL without it, such as/accountforhttps://shop.example.com/account/orders. Get all cookies uses it as an exact-match filter. Get cookies without Get all cookies, and Remove cookies, take no path, as in the browser's own cookie API. They match by URL and Name.Example/- Domain (optional)when Set cookie, or Get cookies with Get all cookies on
The cookie's domain. A leading dot also covers subdomains. When you set a cookie with a domain, the URL is ignored. With Get all cookies, it filters to cookies for this domain.
Example.example.com- sameSite (optional)when Set cookie, with Use JSON format off
strict,laxornone, in any case.no_restrictionalso meansnone, andunspecifiedleaves the choice to the browser. Any other value makes the block fail, with a message naming Strict, Lax and None.Examplelax- expirationDate (seconds) (optional)when Set cookie, with Use JSON format off
How many seconds the cookie lives, counted from when the block runs.
3600keeps it for an hour. Leave it empty for a session cookie, which goes when the profile's browser closes.Example3600- httpOnlywhen Set cookie, with Use JSON format off
Tick it to hide the cookie from the page's own scripts.
ExampleUnchecked- securewhen Set cookie, or Get cookies with Get all cookies on
For Set cookie, tick it to send the cookie over HTTPS only; unticked, it is sent over HTTP too. For Get all cookies, tick it to return only secure cookies. Leave it unticked to return all cookies.
ExampleUnchecked- Assign to variablewhen Get cookies
Stores what the block read in a variable.
ExampleChecked- Variable namewhen Get cookies with Assign to variable on
The variable to store it in. Read it later as
{{variables.sessionCookie.value}}, or{{variables.sessionCookie}}for the whole cookie.ExamplesessionCookie- Insert to tablewhen Get cookies
Also writes what the block read into a table column.
ExampleChecked- Select columnwhen Get cookies with Insert to table on
The column to write to. If you pick none, the value goes to the default
columncolumn.Examplesession
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
Leaves by its only output. Get cookies hands on one cookie, or null if none matches. With Get all cookies, it hands on a list. Each cookie has name, value, domain, path, expires, httpOnly, secure and sameSite. That result goes to the variable and table column you chose. Set cookie and Remove cookies write nothing.
Example: Keep the session cookie after signing in
- Open URL
- Forms
- Click element
- Element exists
- Cookie
- Add Open URL with
https://shop.example.com/login, then Forms blocks for the email and password, and Click element onbutton[type=submit]. - Add Element exists on
.account-menuso the sign-in has finished before you read the cookie. - Add Cookie. Leave the list on Get cookies and Get all cookies unticked.
- Set URL to
https://shop.example.com/and Name tosession_id. - Tick Assign to variable and type
sessionCookie. Tick Insert to table and pick thesessioncolumn. - Use
{{variables.sessionCookie.value}}in later blocks, or read it from the table after the run.
Good to know
- Remove cookies with an empty Name removes every cookie for the URL. If URL is empty too, it removes every cookie in the profile.
- Remove cookies removes every matching cookie that would be sent to the URL, whatever its path.
- Get cookies without Get all cookies and without a URL returns the first cookie with that name from any site.
- In the JSON editor,
expirationDateis a date, not a number of seconds from now. Write it as a Unix time in seconds, such as1798761600. Anexpireskey in the same form works too. - The cookies you read carry
expires(Unix seconds, or-1for a session cookie), notexpirationDate. - Fields accept references, such as
{{variables.token}}in Value (optional) or anywhere in the JSON.
See also
- Open URL — Load a web address in the current tab or a new one, and wait for it to load.
- JavaScript code — Run your own JavaScript in the page, and pass data back to the workflow.
- Element exists — Check whether an element is on the page and continue by one of two outputs.