Ticket #832: sessions.diff
File sessions.diff, 2.2 KB (added by , 19 years ago) |
---|
-
django/conf/global_settings.py
196 196 SESSION_COOKIE_NAME = 'hotclub' # Cookie name. This can be whatever you want. 197 197 SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2 # Age of cookie, in seconds (default: 2 weeks). 198 198 SESSION_COOKIE_DOMAIN = None # A string like ".lawrence.com", or None for standard domain cookie. 199 SESSION_COOKIE_PERSIST = True # Whether session cookies persist across browser sessions. 199 200 SESSION_SAVE_EVERY_REQUEST = False # Whether to save the session data on every request. 200 201 201 202 ######### -
django/middleware/sessions.py
1 from django.conf.settings import SESSION_COOKIE_NAME, SESSION_COOKIE_AGE, SESSION_COOKIE_DOMAIN, SESSION_SAVE_EVERY_REQUEST 1 from django.conf.settings import SESSION_COOKIE_NAME, SESSION_COOKIE_AGE, SESSION_COOKIE_DOMAIN, SESSION_SAVE_EVERY_REQUEST, SESSION_COOKIE_PERSIST 2 2 from django.models.core import sessions 3 3 from django.utils.cache import patch_vary_headers 4 4 import datetime … … 71 71 session_key = request.session.session_key or sessions.get_new_session_key() 72 72 new_session = sessions.save(session_key, request.session._session, 73 73 datetime.datetime.now() + datetime.timedelta(seconds=SESSION_COOKIE_AGE)) 74 expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT") 74 if SESSION_COOKIE_PERSIST: 75 expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT") 76 else: 77 expires = None 75 78 response.set_cookie(SESSION_COOKIE_NAME, session_key, 76 79 max_age=SESSION_COOKIE_AGE, expires=expires, domain=SESSION_COOKIE_DOMAIN) 77 80 return response