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, max_age: 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

    • max_age: number

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

    Returns Soup.Cookie

Properties

name: string

Methods

  • applies_to_uri(uri: GLib.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

  • domain_matches(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
  • get_domain(): string
  • get_http_only(): boolean
  • get_name(): string
  • get_path(): string
  • get_secure(): boolean
  • get_value(): string
  • set_domain(domain: string): 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

    Returns void

  • set_http_only(http_only: 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

    • http_only: boolean

      the new value for the HttpOnly attribute

    Returns void

  • set_max_age(max_age: 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

    • max_age: number

      the new max age

    Returns void

  • set_name(name: string): void
  • set_path(path: string): 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

  • set_secure(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

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

    Returns string

  • to_set_cookie_header(): 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, max_age: 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

    • max_age: 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: GLib.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