简体   繁体   中英

Django let me log in in Firefox but not in chrome

I recently started playing with Django.

When I try to log in into the admin panel, it succeeds in Firefox but doesn't in Google Chrome.

This is the error i get : Forbidden (CSRF cookie not set.): /admin/login/

My cookies are enabled in Chrome for every website. Is there a specific reason why it would work in Firefox but not in Chrome?

Thanks!

I had similar problem and the solution for me was to set Django setting

SESSION_COOKIE_SECURE = False

I know this is the default setting but I've been using production config with this set to True . So in my dev settings I changed it to False and was able to log in to admin panel in Chrome.

On Feb 2020 Chrome implemented a change that enforces that Secure cookies are only accessible via HTTPS protocol. So if you're developing locally and only using HTTP that is a killer. Firefox and Edge are yet to enforce Secure flag |(based on taday's versions)

Are you not developing using the c9 platform?

https://c9.io/

I reset my chrome setting and it worked fine. In Chrome, click on the 3 dots on the far right and goto settings. On settings page, scroll all the way down or click on the bottom left "Reset Settings" button and reset settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM