[Fixed]-Django sets csrftoken twice

1👍

So, I finally figured out what was wrong. In my settings.py file I had the following settings:

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

and this was preventing the browser from setting a correct sessionid/csrftoken.

For these to work, you need a couple of other things, such as CSRF_COOKIE_DOMAIN and SESSION_COOKIE_DOMAIN. I also had those, BUT you also need your server to ensure a secure (https) connection…

Given that I only need this for a school project, https was not mandatory, so I just removed the first two settings, and now everything runs smoothly.

Thanks to everyone that tried to help me.

👤AdelaN

Leave a comment