Ticket #13549: csrf.diff

File csrf.diff, 1.2 KB (added by master, 14 years ago)
  • django/middleware/csrf.py

     
    88import itertools
    99import re
    1010import random
     11import time
    1112
    1213from django.conf import settings
    1314from django.core.urlresolvers import get_callable
    1415from django.utils.cache import patch_vary_headers
    1516from django.utils.hashcompat import md5_constructor
     17from django.utils.http import cookie_date
    1618from django.utils.safestring import mark_safe
    1719
    1820_POST_FORM_RE = \
     
    177179            return response
    178180
    179181        # Set the CSRF cookie even if it's already set, so we renew the expiry timer.
     182        max_age = 60 * 60 * 24 * 7 * 52
    180183        response.set_cookie(settings.CSRF_COOKIE_NAME,
    181                 request.META["CSRF_COOKIE"], max_age = 60 * 60 * 24 * 7 * 52,
     184                request.META["CSRF_COOKIE"], max_age = max_age,
     185                expires = cookie_date(time.time() + max_age),
    182186                domain=settings.CSRF_COOKIE_DOMAIN)
    183187        # Content varies with the CSRF cookie, so set the Vary header.
    184188        patch_vary_headers(response, ('Cookie',))
Back to Top