class HTTPCookie

A cookie sent from an HTTP server to be stored on the client and returned when the path and/or domain matches.

Inheritance diagram

Inheritance diagram of HTTPCookie

__init__() → None

Constructs an empty cookie.

__init__(param0: HTTPCookie) → None
__init__(format: str, url: URLSpec) → None

Constructs a cookie according to the indicated string, presumably the tag of a Set-Cookie header. There is no way to detect a formatting error in the string with this constructor.

__init__(name: str, path: str, domain: str) → None

Constructs a cookie with the indicated name, path, and domain values, but no other data. This is most useful for looking up an existing cookie in the HTTPClient.

clearExpires() → None

Removes the expiration date on the cookie.

getDomain() → str
getExpires() → HTTPDate

Returns the expiration date of the cookie if it is set, or an invalid date if it is not.

Return type


getName() → str

Returns the name of the cookie. This is the key value specified by the server.

getPath() → str

Returns the prefix of the URL paths on the server for which this cookie will be sent.

getSecure() → bool

Returns true if the server has indicated this is a “secure” cookie which should only be sent over an HTTPS channel.

getValue() → str

Returns the value of the cookie. This is the arbitrary string associated with the cookie’s name, as specified by the server.

hasExpires() → bool

Returns true if the cookie has an expiration date, false otherwise.

isExpired(now: HTTPDate) → bool

Returns true if the cookie’s expiration date is before the indicated date, false otherwise.

matchesUrl(url: URLSpec) → bool

Returns true if the cookie is appropriate to send with the indicated URL request, false otherwise.

output(out: ostream) → None
parseSetCookie(format: str, url: URLSpec) → bool

Separates out the parameter/value pairs of the Set-Cookie header and assigns the values of the cookie appropriate. Returns true if the header is parsed correctly, false if something is not understood.

setDomain(domain: str) → None
setExpires(expires: HTTPDate) → None
setName(name: str) → None
setPath(path: str) → None
setSecure(flag: bool) → None
setValue(value: str) → None
updateFrom(other: HTTPCookie) → None

Assuming the operator < method, above, has already evaluated these two cookies as equal, then assign the remaining values (value, expiration date, secure flag) from the indicated cookie. This is guaranteed not to change the ordering of the cookie in a set, and so can be used to update an existing cookie within a set with new values.