PyDocs

Nav

Internet Protocols and Support

Cookie

  • Cookie(version, name, value, port, port_specified, domain, domain_specified, domain_initial_dot, path, path_specified, secure, expires, discard, comment, comment_url, rest, rfc2109=False)
HTTP Cookie.

This class represents both Netscape and RFC 2965 cookies.

This is deliberately a very simple class.  It just holds attributes.  It's
possible to construct Cookie instances that don't comply with the cookie
standards.  CookieJar.make_cookies is the factory function for Cookie
objects -- it deals with cookie parsing, supplying defaults, and
normalising to the representation used in this class.  CookiePolicy is
responsible for checking them to see whether they should be accepted from
and returned to the server.

Note that the port may be present in the headers, but unspecified ("Port"
rather than"Port=80", for example); if this is the case, port is None.
Members of Cookie

c

comment
String comment from the server explaining the function of this cookie, or None.
comment_url
URL linking to a comment from the server explaining the function of this cookie, or None.

d

discard
True if this is a session cookie.
domain
Cookie domain (a string).
domain_initial_dot
True if the domain explicitly specified by the server began with a dot ('.').
domain_specified
True if a domain was explicitly specified by the server.

e

expires
Integer expiry date in seconds since epoch, or None.

g

get_nonstandard_attr
If cookie has the named cookie-attribute, return its value.

h

has_nonstandard_attr
Return True if cookie has the named cookie-attribute.

i

is_expired
True if cookie has passed the time at which the server requested it should expire.

n

name
Cookie name (a string).

p

path
Cookie path (a string, for example, '/acme/rocket_launchers').
port
String representing a port or a set of ports (for example, ‘80’, or ‘80,8080’), or None.
port_specified
True if a port or set of ports was explicitly specified by the server (in the Set-Cookie / Set-Cookie2 header).

r

rfc2109
True if this cookie was received as an RFC 2109 cookie (that is, the cookie arrived in a Set-Cookie header, and the value of the Version cookie-attribute in that header was 1).

s

secure
True if cookie should only be returned over a secure connection.
set_nonstandard_attr
Set the value of the named cookie-attribute.

v

value
Cookie value (a string), or None.
version
Integer or None.
0 Examples
No examples for http.cookiejar/Cookie.
See Also
No see-alsos for http.cookiejar/Cookie
0 Notes
No notes for Cookie