CookieListItem as specified by W3C.

interface CookieListItem {
    domain?: string;
    expires?: number | Date;
    name: string;
    path?: string;
    sameSite?: boolean | "none" | "lax" | "strict";
    secure?: boolean;
    value: string;
}

Hierarchy (view full)

Properties

domain?: string

Specifies the value for the Set-Cookie attribute. By default, no domain is set, and most clients will consider the cookie to apply to only the current domain.

expires?: number | Date

A number of milliseconds or Date interface containing the expires of the cookie.

name: string

A string with the name of a cookie.

path?: string

Specifies the value for the Set-Cookie attribute. By default, the path is considered the "default path".

sameSite?: boolean | "none" | "lax" | "strict"

Specifies the boolean or string to be the value for the Set-Cookie attribute.

  • true will set the SameSite attribute to Strict for strict same site enforcement.
  • false will not set the SameSite attribute.
  • 'lax' will set the SameSite attribute to Lax for lax same site enforcement.
  • 'strict' will set the SameSite attribute to Strict for strict same site enforcement.
  • 'none' will set the SameSite attribute to None for an explicit cross-site cookie.

More information about the different enforcement levels can be found in specification.

note This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.

secure?: boolean

Specifies the boolean value for the Set-Cookie attribute. When truthy, the Secure attribute is set, otherwise it is not. By default, the Secure attribute is not set.

Note be careful when setting this to true, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection.

value: string

A string containing the value of the cookie.