Allow SessionStore's to be easily overridden to make dynamic the session cookie age

101 views
Skip to first unread message

Jaime Herencia

unread,
Nov 6, 2017, 2:47:14 PM11/6/17
to Django developers (Contributions to Django itself)
If I want to make dynamic my SESSION_COOKIE_AGE setting based on certain parameters of the session I need to reimplement in my SessionStore subclasses the following methods:
  • get_expiry_age
  • get_expiry_date
just to override the points where settings.SESSION_COOKIE_AGE is used.

I've created a pull request​ and a ticket where, as you can see, I was told that this could be done via a Middleware but I think that the responsibility of calculating Session expirations should be in the SessionStore by default, so it should be easy to subclass them to change that.



Adam Johnson

unread,
Nov 6, 2017, 3:30:25 PM11/6/17
to django-d...@googlegroups.com
You linked to the wrong PR, here's the right one: https://github.com/django/django/pull/9318

I think Tim's middleware solution isn't that bad, it has the advantage that you can do a lot more logic there too, like use other attributes of request. Plus it works on current Django releases.

That said the patch is small and it also makes SessionBase and I can see the logic in centralizing the settings access, so I'm not against it.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a0225091-86c4-471c-9205-793175a2280e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam
Reply all
Reply to author
Forward
0 new messages