Code

Ticket #5816: 5816.diff

File 5816.diff, 1.2 KB (added by Karen Tracey <kmtracey@…>, 6 years ago)

Restore old date formatting code

Line 
1Index: django/contrib/sessions/middleware.py
2===================================================================
3--- django/contrib/sessions/middleware.py       (revision 6603)
4+++ django/contrib/sessions/middleware.py       (working copy)
5@@ -1,7 +1,6 @@
6 from django.conf import settings
7 from django.utils.cache import patch_vary_headers
8 from email.Utils import formatdate
9-import datetime
10 import time
11 
12 TEST_COOKIE_NAME = 'testcookie'
13@@ -34,9 +33,9 @@
14 
15                     # Fixed length date must have '-' separation in the format
16                     # DD-MMM-YYYY for compliance with Netscape cookie standard
17-                    expires = datetime.datetime.strftime(datetime.datetime.utcnow() + \
18-                              datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT")
19-
20+                    # Note: strftime cannot be used here since it is locale-dependent
21+                    expires = (rfcdate[:7] + "-" + rfcdate[8:11]
22+                               + "-" + rfcdate[12:26] + "GMT")
23                 # Save the seesion data and refresh the client cookie.
24                 request.session.save()
25                 response.set_cookie(settings.SESSION_COOKIE_NAME,