Appearance
UI.COOKIE.set()
Sets a cookie on the current page.
Cookies can only be set for the current page’s domain or subdomain.
Usage
js
UI.COOKIE.set(name: string, value: string)
UI.COOKIE.set(options: object)Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name of the cookie to set |
value | string | Value of the cookie to set |
options | object | Cookie options object (see below) |
Options object
When using UI.COOKIE.set(options), the following properties are supported:
Not sure what these options mean? Learn more about HTTP Cookies from MDN.
| Option | Type | Description |
|---|---|---|
name | string | Required. Name of the cookie |
value | string | Required. Value of the cookie |
secure | boolean | Set a Secure cookie. Secure cookies cannot be set on non-HTTPS pages. By default, this is false. |
httpOnly | boolean | Set a HttpOnly cookie. By default, this is false. |
domain | string | Domain to apply the cookie to. Must match the current page’s domain or subdomain. e.g example.com, app.example.com.By default, this is the current page's domain. |
path | string | Path to apply the cookie to. By default, this is /. |
maxAge | number | Number of seconds until the cookie expires. |
expires | string | Expiry date in GMT format, e.g. Wed, 21 Oct 2015 07:28:00 GMT.Ignored if maxAge is provided. |
Examples
Simple usage
js
I.goTo("https://example.com")
UI.COOKIE.set("foo", "bar")This sets a cookie named "foo" with the value "bar" on https://example.com.
Using the options object
js
UI.COOKIE.set({
name: "foo",
value: "bar",
secure: true,
maxAge: 86400
})Sets a secure cookie "foo" with the value "bar" that expires in 86400 seconds.