部分用户的 CSRF 验证失败
我收到一位用户的投诉,他在尝试登录我的网站(使用 django.contrib.auth.views.login)时不断收到 CSRF 403 错误。
我自己没有遇到此错误,也没有其他用户抱怨此问题。知道它可能是什么吗?我应该如何调试这个?
有没有办法记录有关 CSRF 失败的详细信息,以便我可以尝试在用户登录时检查用户的状态。我不想为外部用户设置 DEBUG=True...
I'm getting complaints from a user who is constantly getting a CSRF 403 error when he tries to login to my site (using django.contrib.auth.views.login).
I don't get this error myself, and have no other users complaining of the issue. Any idea what it could be? How should I go about debugging this?
Is there a way to log detailed information about CSRF failures so I can try to inspect the user's state when they login. I don't want to turn DEBUG=True for an external user...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您对我的评论的回复,我不确定是什么导致了这个问题。我会使用 CSRF_FAILURE_VIEW 来实现自定义视图会给你更多关于正在发生的事情的信息。
Based on your reply to my comment, I am not sure what is causing this issue. I would use CSRF_FAILURE_VIEW to implement a custom view that would give you more information about what is happening.
我最近遇到了这个问题,结果发现这是一个 cookie 问题,因为最终用户禁用了它们。
I recently ran into that and it turned out to be a cookie problem, as in the end user had them disabled.