Cookie

#SoupCookie implements HTTP cookies, as described by <ulink url="http://tools.ietf.org/html/rfc6265.txt">RFC 6265</ulink>.

To have a #SoupSession handle cookies for your appliction automatically, use a #SoupCookieJar.

Constructors

this
this(SoupCookie* soupCookie, bool ownedRef)

Sets our main struct and passes it to the parent class.

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

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

Destructor

~this
~this()
Undocumented in source.

Members

Functions

appliesToUri
bool appliesToUri(URI uri)

Tests if @cookie should be sent to @uri.

copy
Cookie copy()

Copies @cookie.

domainMatches
bool domainMatches(string host)

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.

equal
bool equal(Cookie cookie2)

Tests if @cookie1 and @cookie2 are equal.

free
void free()

Frees @cookie

getCookieStruct
SoupCookie* getCookieStruct(bool transferOwnership)

Get the main Gtk struct

getDomain
string getDomain()

Gets @cookie's domain

getExpires
Date 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
SoupSameSitePolicy getSameSitePolicy()
getSecure
bool getSecure()

Gets @cookie's secure attribute

getStruct
void* getStruct()

the main Gtk struct as a void*

getValue
string getValue()

Gets @cookie's value

setDomain
void setDomain(string domain)

Sets @cookie's domain to @domain

setExpires
void setExpires(Date expires)

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.

setHttpOnly
void setHttpOnly(bool httpOnly)

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.

setMaxAge
void setMaxAge(int maxAge)

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

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(SoupSameSitePolicy policy)

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.

setSecure
void setSecure(bool secure)

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

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 #SoupSession to a server).

toSetCookieHeader
string toSetCookieHeader()

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

Properties

domain
string domain [@property getter]
string domain [@property setter]

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

expires
Date expires [@property getter]
Date expires [@property setter]

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

httpOnly
bool httpOnly [@property getter]
bool httpOnly [@property setter]

%TRUE if the cookie should not be exposed to scripts

name
string name [@property getter]
string name [@property setter]

the cookie name

path
string path [@property getter]
string path [@property setter]

the "path" attribute, or %NULL

secure
bool secure [@property getter]
bool secure [@property setter]

%TRUE if the cookie should only be tranferred over SSL

value
string value [@property getter]
string value [@property setter]

the cookie value

Static functions

getType
GType getType()
parse
Cookie parse(string header, URI origin)

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

Variables

ownedRef
bool ownedRef;
Undocumented in source.
soupCookie
SoupCookie* soupCookie;

the main Gtk struct

Meta

Since

2.24