Skip to main content
rq.cookies is the list of cookies that the host of the current request had when your script started. rq.cookies.jar() gives you the cookie jar, where you can read, set and remove cookies for a URL.
rq.cookies is a copy taken when the script starts. A cookie that your script sets or removes through rq.cookies.jar() does not appear in or disappear from rq.cookies while the script runs. Read it again from the jar with jar.get() or jar.getAll(). Adding to or removing from rq.cookies itself changes only your script’s copy; the jar is not touched.
Using cookie objects in scripts requires the Requestly desktop app, version 2611.5.2 or later. Download it here.

Cookies of the current request

The list is empty when the request’s URL is not http or https, or when you have not allowed scripts to use the cookies of its host. To allow a host, add it in the Domains allowlist tab of the cookie manager.

rq.cookies.get(name)

Type: string | undefined The value of the cookie with this name, decoded. Names are matched ignoring case.

rq.cookies.has(name), rq.cookies.count()

has(name) returns whether a cookie with this name exists, ignoring case. count() returns how many cookies there are.

rq.cookies.one(name)

Type: Cookie | undefined The cookie with this name. See Cookie.

rq.cookies.all(), each(fn), map(fn), filter(fn), find(fn), reduce(fn, initial), idx(index)

Read the cookies as Cookie objects, in order. all() returns an array. filter and find take a function that receives each cookie and its index.

rq.cookies.toObject()

Type: Record<string, string> An object of cookie names to decoded values. The names are in lower case.

rq.cookies.toString()

The cookies as a Cookie header value: name=value pairs joined by ; , with each value as stored (encoded). A cookie has these members. A member is set only when the cookie was given it, so a cookie that does not say secure reads undefined. cookie.valueOf() returns the decoded value. cookie.toString() returns the Set-Cookie line, for example c1=a%20b; Expires=Sat, 02 May 2009 23:38:25 GMT; Path=/; Secure. cookie.toJSON() returns the cookie as an object. cookie.expiry is { type: "session" } or { type: "absolute", date }, as the jar keeps it. rq.cookies.jar() returns the jar. Each method takes a URL, and the host of the URL must be one you allowed scripts to use. A host you have not allowed rejects with an error. Every method returns a promise and also takes an optional callback, (err, result).

jar.get(url, name)

Resolves the decoded value of the cookie, or null when the jar has no such cookie or the cookie has expired.

jar.getAll(url, options?)

Resolves a cookie list, with the same members as rq.cookies. Cookies that have expired are left out. HttpOnly cookies are included unless you pass { http: false }. Secure cookies are included for an https URL, or when you pass { secure: true }.
Stores a cookie and resolves it as a Cookie. The value is stored URI-encoded. You can pass:
  • a name and a value;
  • a cookie object, such as { name, value, path, secure, httpOnly, expires, maxAge, domain, extensions };
  • a Set-Cookie line, such as "sid=abc; Path=/; HttpOnly".
A cookie without a path gets the path of the URL. A maxAge sets the expiry to that many seconds from now, and takes precedence over expires; a maxAge of 0 or less is a cookie that has already expired. A cookie whose domain the URL’s host is not in is refused, and so is a cookie with no name. A name passed with an empty value is read as a Set-Cookie line, not as a name. To set a cookie with an empty value, pass a line such as "sid=".

jar.unset(url, name)

Removes the cookie with this name. It does nothing when there is none.

jar.clear(url)

Removes every cookie the jar holds for the host of the URL.