【发布时间】:2015-08-29 06:45:00
【问题描述】:
使用 Django 1.8,当用户未登录时,我不想在我的网站主页上设置 cookie。所以我用@csrf_exempt 来装饰我的视图
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def mainhome(request):
当我查看查询时,我可以看到 cookie 仍然设置,为什么?
rodo@roz-desktop:~/(master)$ curl -I http://127.0.0.1:8000/
HTTP/1.0 200 OK
Date: Sat, 13 Jun 2015 08:59:27 GMT
Server: WSGIServer/0.1 Python/2.7.8
Content-Type: text/html; charset=utf-8
Vary: Cookie
X-QueryInspect-Duplicate-SQL-Queries: 2
X-QueryInspect-Total-SQL-Time: 34 ms
X-QueryInspect-Total-Request-Time: 283 ms
X-QueryInspect-Num-SQL-Queries: 3
Set-Cookie: csrftoken=sa5x0DyxgBamca0D84ZZnzl2WAL0evkv; expires=Sat, 11-Jun-2016 08:59:27 GMT; Max-Age=31449600; Path=/
【问题讨论】: