Gjsify LogoGjsify Logo

An HTTP cookie.

name and value will be set for all cookies. If the cookie is generated from a string that appears to have no name, then name will be the empty string.

domain and path give the host or domain, and path within that host/domain, to restrict this cookie to. If domain starts with ".", that indicates a domain (which matches the string after the ".", or any hostname that has domain as a suffix). Otherwise, it is a hostname and must match exactly.

expires will be non-%NULL if the cookie uses either the original "expires" attribute, or the newer "max-age" attribute. If expires is %NULL, it indicates that neither "expires" nor "max-age" was specified, and the cookie expires at the end of the session.

If http_only is set, the cookie should not be exposed to untrusted code (eg, javascript), so as to minimize the danger posed by cross-site scripting attacks.

record

Hierarchy

  • Cookie

Index

Constructors

  • new Cookie(name: string, value: string, domain: string, path: string, maxAge: number): Soup.Cookie
  • Creates a new #SoupCookie with the given attributes. (Use soup_cookie_set_secure() and soup_cookie_set_http_only() if you need to set those attributes on the returned cookie.)

    If domain starts with ".", that indicates a domain (which matches the string after the ".", or any hostname that has domain as a suffix). Otherwise, it is a hostname and must match exactly.

    max_age is used to set the "expires" attribute on the cookie; pass -1 to not include the attribute (indicating that the cookie expires with the current session), 0 for an already-expired cookie, or a lifetime in seconds. You can use the constants %SOUP_COOKIE_MAX_AGE_ONE_HOUR, %SOUP_COOKIE_MAX_AGE_ONE_DAY, %SOUP_COOKIE_MAX_AGE_ONE_WEEK and %SOUP_COOKIE_MAX_AGE_ONE_YEAR (or multiples thereof) to calculate this value. (If you really care about setting the exact time that the cookie will expire, use soup_cookie_set_expires().)

    Parameters

    • name: string

      cookie name

    • value: string

      cookie value

    • domain: string

      cookie domain or hostname

    • path: string

      cookie path, or %NULL

    • maxAge: number

      max age of the cookie, or -1 for a session cookie

    Returns Soup.Cookie

Properties

domain: string

the "domain" attribute, or else the hostname that the cookie came from.

field
expires: Soup.Date

the cookie expiration time, or %NULL for a session cookie

field
httpOnly: boolean

%TRUE if the cookie should not be exposed to scripts

field
name: string

the cookie name

field
path: string

the "path" attribute, or %NULL

field
secure: boolean

%TRUE if the cookie should only be tranferred over SSL

field
value: string

the cookie value

field
name: string

Methods

  • appliesToUri(uri: Soup.URI): boolean
  • Tests if cookie should be sent to uri.

    (At the moment, this does not check that cookie's domain matches uri, because it assumes that the caller has already done that. But don't rely on that; it may change in the future.)

    Parameters

    Returns boolean

  • domainMatches(host: string): boolean
  • Checks if the cookie's domain and host match in the sense that cookie should be sent when making a request to host, or that cookie should be accepted when receiving a response from host.

    Parameters

    • host: string

      a URI

    Returns boolean

  • Tests if cookie1 and cookie2 are equal.

    Note that currently, this does not check that the cookie domains match. This may change in the future.

    Parameters

    Returns boolean

  • free(): void
  • getDomain(): string
  • getHttpOnly(): boolean
  • getName(): string
  • getPath(): string
  • getSecure(): boolean
  • getValue(): string
  • setDomain(domain: string): void
  • Sets cookie's domain to domain

    Parameters

    • domain: string

      the new domain

    Returns void

  • Sets cookie's expiration time to expires. If expires is %NULL, cookie will be a session cookie and will expire at the end of the client's session.

    (This sets the same property as soup_cookie_set_max_age().)

    Parameters

    • expires: Soup.Date

      the new expiration time, or %NULL

    Returns void

  • setHttpOnly(httpOnly: boolean): void
  • Sets cookie's HttpOnly attribute to http_only. If %TRUE, cookie will be marked as "http only", meaning it should not be exposed to web page scripts or other untrusted code.

    Parameters

    • httpOnly: boolean

      the new value for the HttpOnly attribute

    Returns void

  • setMaxAge(maxAge: number): void
  • Sets cookie's max age to max_age. If max_age is -1, the cookie is a session cookie, and will expire at the end of the client's session. Otherwise, it is the number of seconds until the cookie expires. You can use the constants %SOUP_COOKIE_MAX_AGE_ONE_HOUR, %SOUP_COOKIE_MAX_AGE_ONE_DAY, %SOUP_COOKIE_MAX_AGE_ONE_WEEK and %SOUP_COOKIE_MAX_AGE_ONE_YEAR (or multiples thereof) to calculate this value. (A value of 0 indicates that the cookie should be considered already-expired.)

    (This sets the same property as soup_cookie_set_expires().)

    Parameters

    • maxAge: number

      the new max age

    Returns void

  • setName(name: string): void
  • Sets cookie's name to name

    Parameters

    • name: string

      the new name

    Returns void

  • setPath(path: string): void
  • Sets cookie's path to path

    Parameters

    • path: string

      the new path

    Returns void

  • When used in conjunction with soup_cookie_jar_get_cookie_list_with_same_site_info() this sets the policy of when this cookie should be exposed.

    Parameters

    Returns void

  • setSecure(secure: boolean): void
  • Sets cookie's secure attribute to secure. If %TRUE, cookie will only be transmitted from the client to the server over secure (https) connections.

    Parameters

    • secure: boolean

      the new value for the secure attribute

    Returns void

  • setValue(value: string): void
  • Sets cookie's value to value

    Parameters

    • value: string

      the new value

    Returns void

  • toCookieHeader(): string
  • Serializes cookie in the format used by the Cookie header (ie, for returning a cookie from a #SoupSession to a server).

    Returns string

  • toSetCookieHeader(): string
  • Serializes cookie in the format used by the Set-Cookie header (ie, for sending a cookie from a #SoupServer to a client).

    Returns string

  • new(name: string, value: string, domain: string, path: string, maxAge: number): Soup.Cookie
  • Creates a new #SoupCookie with the given attributes. (Use soup_cookie_set_secure() and soup_cookie_set_http_only() if you need to set those attributes on the returned cookie.)

    If domain starts with ".", that indicates a domain (which matches the string after the ".", or any hostname that has domain as a suffix). Otherwise, it is a hostname and must match exactly.

    max_age is used to set the "expires" attribute on the cookie; pass -1 to not include the attribute (indicating that the cookie expires with the current session), 0 for an already-expired cookie, or a lifetime in seconds. You can use the constants %SOUP_COOKIE_MAX_AGE_ONE_HOUR, %SOUP_COOKIE_MAX_AGE_ONE_DAY, %SOUP_COOKIE_MAX_AGE_ONE_WEEK and %SOUP_COOKIE_MAX_AGE_ONE_YEAR (or multiples thereof) to calculate this value. (If you really care about setting the exact time that the cookie will expire, use soup_cookie_set_expires().)

    Parameters

    • name: string

      cookie name

    • value: string

      cookie value

    • domain: string

      cookie domain or hostname

    • path: string

      cookie path, or %NULL

    • maxAge: number

      max age of the cookie, or -1 for a session cookie

    Returns Soup.Cookie

  • Parses header and returns a #SoupCookie. (If header contains multiple cookies, only the first one will be parsed.)

    If header does not have "path" or "domain" attributes, they will be defaulted from origin. If origin is %NULL, path will default to "/", but domain will be left as %NULL. Note that this is not a valid state for a #SoupCookie, and you will need to fill in some appropriate string for the domain if you want to actually make use of the cookie.

    Parameters

    • header: string

      a cookie string (eg, the value of a Set-Cookie header)

    • origin: Soup.URI

      origin of the cookie, or %NULL

    Returns Soup.Cookie

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method