twisted.web.http.Request.addCookie(self, k, v, expires=None, domain=None, path=None, max_age=None, comment=None, secure=None, httpOnly=False, sameSite=None)
method documentationtwisted.web.http.Request
View Source
Set an outgoing HTTP cookie.
In general, you should consider using sessions instead of cookies, see twisted.web.server.Request.getSession
and the twisted.web.server.Session
class for details.
Parameters | k | cookie name (type: bytes or unicode ) |
v | cookie value (type: bytes or unicode ) | |
expires | cookie expire attribute value in "Wdy, DD Mon YYYY HH:MM:SS GMT" format (type: bytes or unicode ) | |
domain | cookie domain (type: bytes or unicode ) | |
path | cookie path (type: bytes or unicode ) | |
max_age | cookie expiration in seconds from reception (type: bytes or unicode ) | |
comment | cookie comment (type: bytes or unicode ) | |
secure | direct browser to send the cookie on encrypted connections only (type: bool ) | |
httpOnly | direct browser not to expose cookies through channels other than HTTP (and HTTPS) requests (type: bool ) | |
sameSite | One of None (default), 'lax' or 'strict' . Direct browsers not to send this cookie on cross-origin requests. Please see: https://tools.ietf.org/html/draft-west-first-party-cookies-07 (type: None , bytes or unicode ) | |
Raises | DeprecationWarning if an argument is not bytes or unicode . ValueError if the value for sameSite is not supported. |
Function | _ensureBytes | Ensure that val is bytes, encoding using UTF-8 if needed. |
Function | _sanitize | No summary |