mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33562 -- Made HttpResponse.set_cookie() support timedelta for the max_age argument.
This commit is contained in:
committed by
Mariusz Felisiak
parent
1882f6567d
commit
ae2da5ba65
@@ -853,9 +853,15 @@ Methods
|
||||
Sets a cookie. The parameters are the same as in the
|
||||
:class:`~http.cookies.Morsel` cookie object in the Python standard library.
|
||||
|
||||
* ``max_age`` should be an integer number of seconds, or ``None`` (default)
|
||||
if the cookie should last only as long as the client's browser session.
|
||||
If ``expires`` is not specified, it will be calculated.
|
||||
* ``max_age`` should be a :class:`~datetime.timedelta` object, an integer
|
||||
number of seconds, or ``None`` (default) if the cookie should last only
|
||||
as long as the client's browser session. If ``expires`` is not specified,
|
||||
it will be calculated.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
Support for ``timedelta`` objects was added.
|
||||
|
||||
* ``expires`` should either be a string in the format
|
||||
``"Wdy, DD-Mon-YY HH:MM:SS GMT"`` or a ``datetime.datetime`` object
|
||||
in UTC. If ``expires`` is a ``datetime`` object, the ``max_age``
|
||||
|
||||
@@ -281,7 +281,8 @@ Models
|
||||
Requests and Responses
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ...
|
||||
* :meth:`.HttpResponse.set_cookie` now supports :class:`~datetime.timedelta`
|
||||
objects for the ``max_age`` argument.
|
||||
|
||||
Security
|
||||
~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user