Cookie

Implements HTTP cookies, as described by RFC 6265.

To have a class@Session handle cookies for your appliction automatically, use a class@CookieJar.

@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.

Constructors

this
this(string name, string value, string domain, string path, int maxAge)

Creates a new #SoupCookie with the given attributes.

Members

Functions

appliesToUri
bool appliesToUri(glib.uri.Uri uri)

Tests if cookie should be sent to uri.

copy
soup.cookie.Cookie copy()

Copies cookie.

domainMatches
bool domainMatches(string host)

Checks if the cookie's domain and host match.

equal
bool equal(soup.cookie.Cookie cookie2)

Tests if cookie1 and cookie2 are equal.

getDomain
string getDomain()

Gets cookie's domain.

getExpires
glib.date_time.DateTime getExpires()

Gets cookie's expiration time.

getHttpOnly
bool getHttpOnly()

Gets cookie's HttpOnly attribute.

getName
string getName()

Gets cookie's name.

getPath
string getPath()

Gets cookie's path.

getSameSitePolicy
soup.types.SameSitePolicy getSameSitePolicy()

Returns the same-site policy for this cookie.

getSecure
bool getSecure()

Gets cookie's secure attribute.

getValue
string getValue()

Gets cookie's value.

setDomain
void setDomain(string domain)

Sets cookie's domain to domain.

setExpires
void setExpires(glib.date_time.DateTime expires)

Sets cookie's expiration time to expires.

setHttpOnly
void setHttpOnly(bool httpOnly)

Sets cookie's HttpOnly attribute to http_only.

setMaxAge
void setMaxAge(int maxAge)

Sets cookie's max age to max_age.

setName
void setName(string name)

Sets cookie's name to name.

setPath
void setPath(string path)

Sets cookie's path to path.

setSameSitePolicy
void setSameSitePolicy(soup.types.SameSitePolicy policy)

When used in conjunction with soup.cookie_jar.CookieJar.getCookieListWithSameSiteInfo this sets the policy of when this cookie should be exposed.

setSecure
void setSecure(bool secure)

Sets cookie's secure attribute to secure.

setValue
void setValue(string value)

Sets cookie's value to value.

toCookieHeader
string toCookieHeader()

Serializes cookie in the format used by the Cookie header (ie, for returning a cookie from a classSession to a server).

toSetCookieHeader
string toSetCookieHeader()

Serializes cookie in the format used by the Set-Cookie header.

Static functions

parse
soup.cookie.Cookie parse(string header, glib.uri.Uri origin)

Parses header and returns a #SoupCookie.

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.