Taiko
Documentation

Home / API Reference

setCookie

Sets a cookie with the given cookie data. It may overwrite equivalent cookie if it already exists.

Examples

await setCookie("CSRFToken","csrfToken", {url: "http://the-internet.herokuapp.com"})
await setCookie("CSRFToken","csrfToken", {domain: "herokuapp.com"})

Parameters


name

Cookie name.


value

Cookie value.


options

options.url string

sets cookie with the URL.

Default value
undefined

options.domain string

sets cookie with the exact domain.

Default value
undefined

options.path string

sets cookie with the exact path.

Default value
undefined

options.secure boolean

True if cookie to be set is secure.

Default value
undefined

options.httpOnly boolean

True if cookie to be set is http-only.

Default value
undefined

options.sameSite string

Represents the cookie's 'SameSite' status: Refer https://tools.ietf.org/html/draft-west-first-party-cookies.

Default value
undefined

options.expires number

UTC time in seconds, counted from January 1, 1970. eg: 2019-02-16T16:55:45.529Z

Default value
undefined

Returns

Promise