#32129: Confusing documentation on how to get cookie's time until it expires in
seconds.
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: Sarah
Type: | Boyce
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: session cookies | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* needs_better_patch: 0 => 1
Comment:
> What is the use case of passing in modification ?
That's needed in order to get the remaining time, rather than the ''max
age'', which is what these methods are originally for.
Comment from Aymeric #18458:
> I recently worked on this code and came to the conclusion that
get_expiry_age and get_expiry_date are designed to work at the time when
the session is saved, and not at any other point in time.
https://code.djangoproject.com/ticket/18458#comment:2
Adding the `modification` parameter allows working out the remaining time
(modulo a certain expiry) — the commit for #18458 notes it as a testing
aid, and for allowing file backed session invalidation.
The interesting thing with the file case if you can stat for the
`modified` where otherwise you don't really have that in hand... 🤔
I've left a
[https://github.com/django/django/pull/15549#pullrequestreview-925855361
comment on PR]
Last bit:
> Overall, perhaps an admonition steering people away from this API would
be better: assuming I've got modification in hand (which I need for this
use-case) I think I'd just do:
>
> expires_at = modification +
timedelta(seconds=settings.SESSION_COOKIE_AGE)
>
> ... and not use these methods at all. (Loops back to comment from #18458
at the top...)
--
Ticket URL: <https://code.djangoproject.com/ticket/32129#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107017fda6840aa-3b9154e4-9c25-47e6-a8e5-23ffa3b373bf-000000%40eu-central-1.amazonses.com.