extend cookie age if its still used
This commit is contained in:
parent
d3c3378267
commit
5e6b054896
2 changed files with 18 additions and 0 deletions
|
@ -87,6 +87,7 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'ox.django.middleware.ExceptionMiddleware',
|
'ox.django.middleware.ExceptionMiddleware',
|
||||||
'ox.django.middleware.ChromeFrameMiddleware',
|
'ox.django.middleware.ChromeFrameMiddleware',
|
||||||
|
'user.middleware.UpdateSession',
|
||||||
)
|
)
|
||||||
|
|
||||||
ROOT_URLCONF = 'urls'
|
ROOT_URLCONF = 'urls'
|
||||||
|
@ -205,6 +206,9 @@ MEDIA_PREFIX=''
|
||||||
|
|
||||||
SESSION_COOKIE_AGE=60*24*60*60
|
SESSION_COOKIE_AGE=60*24*60*60
|
||||||
|
|
||||||
|
# Extend cookie age if session is older
|
||||||
|
SESSION_UPDATE=24*60*60
|
||||||
|
|
||||||
SCRIPT_ROOT = normpath(join(PROJECT_ROOT, '..', 'scripts'))
|
SCRIPT_ROOT = normpath(join(PROJECT_ROOT, '..', 'scripts'))
|
||||||
#change script to customize
|
#change script to customize
|
||||||
ITEM_POSTER = join(SCRIPT_ROOT, 'poster.py')
|
ITEM_POSTER = join(SCRIPT_ROOT, 'poster.py')
|
||||||
|
|
14
pandora/user/middleware.py
Normal file
14
pandora/user/middleware.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.sessions.models import Session
|
||||||
|
|
||||||
|
class UpdateSession(object):
|
||||||
|
def process_request(self, request):
|
||||||
|
if request.user.is_authenticated():
|
||||||
|
expire_date = Session.objects.get(session_key=request.session.session_key).expire_date
|
||||||
|
if (request.session.get_expiry_date() - expire_date).total_seconds() > settings.SESSION_UPDATE:
|
||||||
|
request.session.modified = True
|
||||||
|
|
||||||
|
def process_response(self, request, response):
|
||||||
|
return response
|
Loading…
Reference in a new issue