Ticket #13549: csrf.diff
File csrf.diff, 1.2 KB (added by , 15 years ago) |
---|
-
django/middleware/csrf.py
8 8 import itertools 9 9 import re 10 10 import random 11 import time 11 12 12 13 from django.conf import settings 13 14 from django.core.urlresolvers import get_callable 14 15 from django.utils.cache import patch_vary_headers 15 16 from django.utils.hashcompat import md5_constructor 17 from django.utils.http import cookie_date 16 18 from django.utils.safestring import mark_safe 17 19 18 20 _POST_FORM_RE = \ … … 177 179 return response 178 180 179 181 # Set the CSRF cookie even if it's already set, so we renew the expiry timer. 182 max_age = 60 * 60 * 24 * 7 * 52 180 183 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), 182 186 domain=settings.CSRF_COOKIE_DOMAIN) 183 187 # Content varies with the CSRF cookie, so set the Vary header. 184 188 patch_vary_headers(response, ('Cookie',))