tough-cookie.cookiejar.setcookie_2.md

July 9, 2025 ยท View on GitHub

Home > tough-cookie > CookieJar > setCookie

CookieJar.setCookie() method

Attempt to set the Cookie in the CookieJar.

Signature:

setCookie(cookie: string | Cookie, url: string | URL, options?: SetCookieOptions): Promise<Cookie | undefined>;

Parameters

Parameter

Type

Description

cookie

string | Cookie

The cookie object or cookie string to store. A string value will be parsed into a cookie using Cookie.parse().

url

string | URL

The domain to store the cookie with.

options

SetCookieOptions

(Optional) Configuration settings to use when storing the cookie.

Returns:

Promise<Cookie | undefined>

Remarks