The Python Oracle

SESSION_COOKIE_SECURE=True in Django 2.2 redirects Admin login to itself

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC E Schuberts Piano Sonata D 784 in A

--

Chapters
00:00 Question
01:39 Accepted answer (Score 4)
01:59 Answer 2 (Score 0)
02:26 Thank you

--

Full question
https://stackoverflow.com/questions/5642...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #sessioncookies

#avk47



ACCEPTED ANSWER

Score 4


Actually, the following works.

SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

It is just that testing in on my development environment, HTTPS is not available.




ANSWER 2

Score 0


It seems the SESSION_COOKIE_SECURE option works correctly only under the HTTPS connection.

But, I have no idea why does it work under HTTP in my local environment with default Django's manage.py runserver but not Nginx / gunicorn in production...