[Django] #28763: Allow SessionStore's to easily override or make dynamic the session cookie age

14 views
Skip to first unread message

Django

unread,
Nov 1, 2017, 8:25:28 AM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to easily override or make dynamic the session cookie
age
-------------------------------------------------+------------------------
Reporter: Jaime Herencia Enjuto | Owner: nobody
Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28763>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 1, 2017, 8:40:35 AM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to easily override or make dynamic the session cookie
age
-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: nobody
Enjuto |

Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jaime Herencia Enjuto):

* has_patch: 0 => 1


Comment:

I've created a pull request: https://github.com/django/django/pull/9314

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:1>

Django

unread,
Nov 1, 2017, 8:52:01 AM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age

-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: nobody
Enjuto |
Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:2>

Django

unread,
Nov 1, 2017, 5:41:26 PM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age
-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: Tomer
Enjuto | Chachamu
Type: New feature | Status: assigned
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tomer Chachamu):

* owner: nobody => Tomer Chachamu
* status: new => assigned
* stage: Unreviewed => Accepted


Comment:

That seems useful.

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:3>

Django

unread,
Nov 1, 2017, 5:56:05 PM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age
-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: (none)
Enjuto |

Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tomer Chachamu):

* status: assigned => new
* owner: Tomer Chachamu => (none)
* stage: Accepted => Unreviewed


Comment:

Actually, it looks like you can call `SessionStore.set_expiry`? One place
to do so would be in a middleware that's listed below the session
middleware, when processing a response.

{{{
class SessionExpiryPolicyMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):

response = self.get_response(request)

if response.session.modified and response.status_code != 500:
response.session.set_expiry(response.session.calculate_expiry())

return response

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:4>

Django

unread,
Nov 1, 2017, 6:27:49 PM11/1/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age

-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: (none)
Enjuto |
Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jaime Herencia Enjuto):

You are right that could be a way to achieve this, I know there are other
ways to do this but don't you think that the responsible of calculating
Session expirations should be the SessionStore not a middleware?

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:5>

Django

unread,
Nov 6, 2017, 6:50:17 AM11/6/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age

-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: (none)
Enjuto |
Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tomer Chachamu):

I think it would be worth discussing in the django-developers mailing
list.

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:6>

Django

unread,
Dec 28, 2017, 11:35:31 AM12/28/17
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age

-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: (none)
Enjuto |
Type: New feature | Status: new
Component: contrib.sessions | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_tests: 0 => 1


* stage: Unreviewed => Accepted


Comment:

A test should be added so the change isn't inadvertently refactored away.

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:7>

Django

unread,
May 20, 2019, 3:21:53 AM5/20/19
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age
-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: Hasan
Enjuto | Ramezani

Type: New feature | Status: assigned
Component: contrib.sessions | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => assigned

* owner: (none) => Hasan Ramezani
* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/11389 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:8>

Django

unread,
May 21, 2019, 3:08:34 AM5/21/19
to django-...@googlegroups.com
#28763: Allow SessionStore's to be easily overridden to make dynamic the session
cookie age

-------------------------------------+-------------------------------------
Reporter: Jaime Herencia | Owner: Hasan
Enjuto | Ramezani
Type: New feature | Status: closed
Component: contrib.sessions | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"9d6f981a66bd2c4188c4a3e08e4f36fc9c4882ef" 9d6f981a]:
{{{
#!CommitTicketReference repository=""
revision="9d6f981a66bd2c4188c4a3e08e4f36fc9c4882ef"
Fixed #28763 -- Allowed overriding the session cookie age with
SessionStore.get_session_cookie_age().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28763#comment:9>

Reply all
Reply to author
Forward
0 new messages