Vous devez avoir un compte Developpez.com et être connecté pour pouvoir participer aux discussions.

Mot de passe
Mot de passe oublié ?
Créer un compte

Vous n'avez pas encore de compte Developpez.com ? L'inscription est gratuite et ne vous prendra que quelques instants !

Je m'inscris !



Choisissez la catégorie, puis la rubrique :

18.22.5 Cookie Objects

18.22.5 Cookie Objects

Cookie instances have Python attributes roughly corresponding to the standard cookie-attributes specified in the various cookie standards. The correspondence is not one-to-one, because there are complicated rules for assigning default values, because the max-age and expires cookie-attributes contain equivalent information, and because RFC 2109 cookies may be 'downgraded' by cookielib from version 1 to version 0 (Netscape) cookies.

Assignment to these attributes should not be necessary other than in rare circumstances in a CookiePolicy method. The class does not enforce internal consistency, so you should know what you're doing if you do that.

Integer or None. Netscape cookies have version 0. RFC 2965 and RFC 2109 cookies have a version cookie-attribute of 1. However, note that cookielib may 'downgrade' RFC 2109 cookies to Netscape cookies, in which case version is 0.
Cookie name (a string).
Cookie value (a string), or None.
String representing a port or a set of ports (eg. '80', or '80,8080'), or None.
Cookie path (a string, eg. '/acme/rocket_launchers').
True if cookie should only be returned over a secure connection.
Integer expiry date in seconds since epoch, or None. See also the is_expired() method.
True if this is a session cookie.
String comment from the server explaining the function of this cookie, or None.
URL linking to a comment from the server explaining the function of this cookie, or None.
True if this cookie was received as an RFC 2109 cookie (ie. the cookie arrived in a Set-Cookie: header, and the value of the Version cookie-attribute in that header was 1). This attribute is provided because cookielib may 'downgrade' RFC 2109 cookies to Netscape cookies, in which case version is 0. New in version 2.5.

True if a port or set of ports was explicitly specified by the server (in the Set-Cookie: / Set-Cookie2: header).
True if a domain was explicitly specified by the server.
True if the domain explicitly specified by the server began with a dot ('.').

Cookies may have additional non-standard cookie-attributes. These may be accessed using the following methods:

has_nonstandard_attr( name)
Return true if cookie has the named cookie-attribute.
get_nonstandard_attr( name, default=None)
If cookie has the named cookie-attribute, return its value. Otherwise, return default.
set_nonstandard_attr( name, value)
Set the value of the named cookie-attribute.

The Cookie class also defines the following method:

is_expired( [now=None])
True if cookie has passed the time at which the server requested it should expire. If now is given (in seconds since the epoch), return whether the cookie has expired at the specified time.

See About this document... for information on suggesting changes.
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web