Failed to match request state with session state

All of a sudden my login via Microsoft AD (Active Directory) is broken.

Post logging in, redirect to http://localhost:8000/auth/redirect? gives

AuthSecurityError at /auth/redirect
Failed to match request state with session state
Request Method: GET
Request URL:    http://localhost:8000/auth/redirect?code=0.xxxm&state=xxxx-xxxx-xxxx-xxxx-xxxx&session_state=xxxx-xxxx-xxxx-xxxx-xxxx
Django Version: 4.2.5
Exception Type: AuthSecurityError
Exception Value:
Failed to match request state with session state
Exception Location: D:\workspace\django\projectX\env\lib\site-packages\ms_identity_web\, line 259, in _verify_state
Raised during:  ms_identity_web.django.msal_views_and_urls.aad_redirect
Python Executable:  D:\workspace\django\projectX\env\Scripts\python.exe
Python Version: 3.10.10

How can I know what went wrong all of a sudden ?

Hello. Did you find out any solution for this error. Same issue I am facing in my website now.

Somewhere other than in django_session, some sort of session data is getting stored.
DROP DATABASE and create new database and do makemigrations and migrate - it started working for me again. Same happened on my colleague’s machine and database refresh was the only way to go.

This happens to me when I switch branches in git which (required a database migrate).

Hi. I am sorry but i did not get your point. How we can drop database and create new one. I am directly accessing Views from Azure sql server not models. So their is no use of migration and migrate. I have create connection string in and using that in all views in sql querirs.
def connection_string():
conn1 = pyodbc.connect(‘DRIVER={ODBC Driver 17 for SQL Server};’ +
‘SERVER=;’ +
‘UID=;’ +
‘PWD=;’ +
return conn1
somewhere like this.

I was referring to my localhost - I still haven’t deployed to our Azure account.
I deleted the database and re-created it by using python makemigrations and python migrate - this is a bad choice but this was the only solution I found.
You can pour your thoughts here which is the official github for AD.