Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cookie

Represents an HTTP Cookie.

All cookies must have a name and a value and can optionally have other fields set such as path, domain, etc.

Hierarchy

  • Cookie

Index

Methods

encode

  • encode(): string
  • Encode the cookie to a string. This is what is used in the Set-Cookie header

    Returns string

getDomain

  • getDomain(): string | null
  • Returns string | null

getMaxAge

  • getMaxAge(): number
  • Returns number

getName

  • getName(): string
  • Returns string

getPath

  • getPath(): string | null
  • Returns string | null

getSameSite

  • Returns CookieSameSite | null

getValue

  • getValue(): string
  • Returns string

isHttpOnly

  • isHttpOnly(): boolean
  • Returns boolean

isSecure

  • isSecure(): boolean
  • Returns boolean

setDomain

  • setDomain(domain: string | null | undefined): Cookie
  • Sets the domain of this cookie

    Parameters

    • domain: string | null | undefined

    Returns Cookie

setHttpOnly

  • setHttpOnly(httpOnly: boolean): Cookie
  • Determines if this cookie is HTTP only. If set to true, this cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For for information, please look here.

    Parameters

    • httpOnly: boolean

    Returns Cookie

setMaxAge

  • setMaxAge(maxAge: number): Cookie
  • Sets the maximum age of this cookie in seconds. If an age of 0 is specified, this cookie will be automatically removed by browser because it will expire immediately. If MIN_VALUE is specified, this cookie will be removed when the browser is closed. If you don't set this the cookie will be a session cookie and be removed when the browser is closed.

    Parameters

    • maxAge: number

    Returns Cookie

setPath

  • setPath(path: string | null | undefined): Cookie
  • Sets the path of this cookie.

    Parameters

    • path: string | null | undefined

    Returns Cookie

setSameSite

  • Sets the same site of this cookie.

    Parameters

    Returns Cookie

setSecure

  • setSecure(secure: boolean): Cookie
  • Sets the security getStatus of this cookie

    Parameters

    • secure: boolean

    Returns Cookie

setValue

  • setValue(value: string): Cookie
  • Sets the value of this cookie

    Parameters

    • value: string

    Returns Cookie

Static cookie

  • cookie(name: string, value: string): Cookie
  • Create a new cookie

    Parameters

    • name: string
    • value: string

    Returns Cookie

Generated using TypeDoc