In my Django project, until recently I had left the settings SESSION_COOKIE_DOMAIN
and CSRF_COOKIE_DOMAIN
unset. Recently I changed them to .mydomain.com
and since then I have been seeing sporadic CSRF failures on AJAX requests for certain users. The failure manifests as a 403 with CSRF token missing or incorrect.
appearing in the logs.
Asking users to clear cookies seems to resolve the issue, but I'm wondering how the settings change could have caused this and why it only seems to be happening for some users and not others.
Wondering if there is a way to resolve these issues without asking my users to clear cookies.