Opened 18 years ago

Closed 18 years ago

Last modified 16 years ago

#508 closed defect (fixed)

max_age for cookies doesn't work in safari (and perhaps not IE)

Reported by: mark@… Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The max_age setting for a cookie is ignored in safari. set_cookie needs to support expires.

Attachments (1)

cookie.patch (1.6 KB) - added by Andreas 18 years ago.
"expires"-attribute for sessions and cookies

Download all attachments as: .zip

Change History (4)

comment:1 Changed 18 years ago by mark@…

here is a patch to allow expired to be used as well

Index: django/utils/
--- django/utils/ (revision 640)
+++ django/utils/ (working copy)
@@ -168,9 +168,9 @@

return True

return False

  • def set_cookie(self, key, value=, max_age=None, path='/', domain=None, secure=None):

+ def set_cookie(self, key, value=, max_age=None, expires=None, path='/', domain=None, secure=None):

self.cookies[key] = value

  • for var in ('max_age', 'path', 'domain', 'secure'):

+ for var in ('max_age', 'path', 'domain', 'secure' , 'expires'):

val = locals()[var]
if val is not None:

self.cookies[key][var.replace('_', '-')] = val

comment:2 Changed 18 years ago by Andreas

Cookies and Sessions were per-browser-session-only for me in both IE 6 and Opera 8.5. I'll attach a patch in a minute.

Changed 18 years ago by Andreas

Attachment: cookie.patch added

"expires"-attribute for sessions and cookies

comment:3 Changed 18 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [1035]) Fixed #508 -- Added support for 'expires' in cookies and changed session middleware to set 'expires' in addition to 'max_age'. Thanks, mark@…

Note: See TracTickets for help on using tickets.
Back to Top