Django SESSION_COOKIE_DOMAIN

I see something cryptic with setting SESSION_COOKIE_DOMAIN in django.

Usually, when I set this parameter to ".mydomain.net", it works fine. But sometimes cookies do not seem to be set, because when I log in, I don’t remember the session, and I become AnonymousUser when I go to the next page.

In these circumstances, if, I change my settings file so that SESSION_COOKIE_DOMAIN is now None or "", then the behavior of the site returns to normal. If I change SESSION_COOKIE_DOMAIN to mydomain, the problem will return.

Any ideas? Perhaps this will be a quiet failure in the settings? Or could this be due to my server configuration? Or the car that I am accessing the site?

+3
source share
3 answers

In all likelihood, you get several sessionid cookies sent. If you have a sessionid cookie with the domain "example.com" and another cookie with the domain ".example.com", Django will only check one of these sessionid values. I'm not sure how Django decides what value sessionid checks for validity.

+1
source

Check your cookies in your browser (in FF, Tools → Options → Privacy → Something about cookies) and check if they are set correctly. Find your domain and see if a cookie is set sessionid.

0
source

, . , HTTP Firebug Live HTTP Headers Firefox. cookie?

0

Source: https://habr.com/ru/post/1716929/


All Articles