Django - Forbidden (CSRF cookie not set.)

穿精又带淫゛_ 提交于 2019-12-04 07:50:23

As I had mentioned in my main comment, you will see that error when a 403 is raised because of a CSRF failure.

You should not need to worry about trying to handle CSRF protection against users without cookies enabled. The very nature of a CSRF attack requires the use of browser cookies. If they are not used, the CSRF-protected request will fail (as you have seen). Thus, you are still protected.

Django lets you set a specific view to use for the client in the event of a CSRF failure: https://docs.djangoproject.com/en/dev/ref/settings/#std%3asetting-CSRF_FAILURE_VIEW

Really, you should not need to do anything other than note that there are requests that are trying to POST to your server in an invalid way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!