Asinox
Asinox

Reputation: 6865

Django SESSION_COOKIE_DOMAIN error

I'm trying to using SESSION_COOKIE_DOMAIN, but I get an error in any browser I try when I try to log into the admin:

Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again.

Any idea?

Upvotes: 1

Views: 1051

Answers (3)

George Cummins
George Cummins

Reputation: 28906

In certain circumstances, server-side caching may be the culprit here. We use Varnish to create cache on certain high-traffic sites, and found that it interferes with CSRF validation. The version of the CSRF token that is served from cache will likely be invalid if the cache is more than a few seconds old.

You may need to disable server-side caching for login forms (/admin, for example) and other places where CSRF is used.

Upvotes: 0

Jay
Jay

Reputation: 702

This usually indicates that you have misconfigured your SESSION_COOKIE_DOMAIN setting. Can you provide more info?

What domain are you running your app on? What is the current value of SESSION_COOKIE_DOMAIN?

Upvotes: 0

adam
adam

Reputation: 6738

One thing you might want to look into is the setting SESSION_COOKIE_SECURE. If it's set to True make sure you are using https. Otherwise, set it to False and use http.

Upvotes: 1

Related Questions