Skip to content

Latest commit

 

History

History
151 lines (68 loc) · 2.53 KB

tough-cookie.setcookieoptions.md

File metadata and controls

151 lines (68 loc) · 2.53 KB

Home > tough-cookie > SetCookieOptions

SetCookieOptions interface

Configuration options used when calling CookieJar.setCookie(...)

Signature:

export interface SetCookieOptions 

Properties

Property

Modifiers

Type

Description

http?

boolean | undefined

(Optional) Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies.

Defaults to true if not provided.

ignoreError?

boolean | undefined

(Optional) Silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option.

Defaults to false if not provided.

loose?

boolean | undefined

(Optional) Controls if a cookie string should be parsed using loose mode or not. See Cookie.parse() and ParseCookieOptions for more details.

Defaults to false if not provided.

now?

Date | undefined

(Optional) Forces the cookie creation and access time of cookies to this value when stored.

Defaults to Date.now() if not provided.

sameSiteContext?

'strict' | 'lax' | 'none' | undefined

(Optional) Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon storage.

  • 'strict' - If the request is on the same "site for cookies" (see the RFC draft for more information), pass this option to add a layer of defense against CSRF.

  • 'lax' - If the request is from another site, but is directly because of navigation by the user, such as, <link type=prefetch> or <a href="...">, then use lax.

  • 'none' - This indicates a cross-origin request.

  • undefined - SameSite is not be enforced! This can be a valid use-case for when CSRF isn't in the threat model of the system being built.

Defaults to undefined if not provided.