Ticket #13548: set_cookie.diff

File set_cookie.diff, 1.1 KB (added by master, 15 years ago)
  • django/http/__init__.py

     
    11import os
    22import re
     3import time
    34from Cookie import BaseCookie, SimpleCookie, CookieError
    45from pprint import pformat
    56from urllib import urlencode
     
    1213
    1314from django.utils.datastructures import MultiValueDict, ImmutableList
    1415from django.utils.encoding import smart_str, iri_to_uri, force_unicode
     16from django.utils.http import cookie_date
    1517from django.http.multipartparser import MultiPartParser
    1618from django.conf import settings
    1719from django.core.files import uploadhandler
     
    373375
    374376    def set_cookie(self, key, value='', max_age=None, expires=None, path='/',
    375377                   domain=None, secure=False):
     378        # IE doesn't support the max-age property
     379        if max_age is not None and expires is None:
     380            expires = cookie_date(time.time() + max_age)
    376381        self.cookies[key] = value
    377382        if max_age is not None:
    378383            self.cookies[key]['max-age'] = max_age
Back to Top