Ticket #508: cookie.patch

File cookie.patch, 1.6 KB (added by Andreas, 19 years ago)

"expires"-attribute for sessions and cookies

Line 
1Index: middleware/sessions.py
2===================================================================
3--- middleware/sessions.py (revision 773)
4+++ middleware/sessions.py (working copy)
5@@ -69,6 +69,8 @@
6 session_key = request.session.session_key or sessions.get_new_session_key()
7 new_session = sessions.save(session_key, request.session._session,
8 datetime.datetime.now() + datetime.timedelta(seconds=SESSION_COOKIE_AGE))
9+ SESSION_COOKIE_EXPIRES = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(seconds=SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT")
10 response.set_cookie(SESSION_COOKIE_NAME, session_key,
11- max_age=SESSION_COOKIE_AGE, domain=SESSION_COOKIE_DOMAIN)
12+ max_age=SESSION_COOKIE_AGE, expires=SESSION_COOKIE_EXPIRES, domain=SESSION_COOKIE_DOMAIN)
13 return response
14Index: utils/httpwrappers.py
15===================================================================
16--- utils/httpwrappers.py (revision 773)
17+++ utils/httpwrappers.py (working copy)
18@@ -172,9 +172,9 @@
19 return True
20 return False
21
22- def set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=None):
23+ def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
24 self.cookies[key] = value
25- for var in ('max_age', 'path', 'domain', 'secure'):
26+ for var in ('max_age', 'path', 'domain', 'secure' , 'expires'):
27 val = locals()[var]
28 if val is not None:
29 self.cookies[key][var.replace('_', '-')] = val
Back to Top