Session doesn't persist in Firefox

Hi, My Django project which works in Chrome but when i try to login in Firefox it successfully login and redirect to home page but after login when i navigate to other paths it redirects me to login page. My views have login_required decorator but that is not the issue. When i check in the web console it creates session_id data after login but if i switch path, that session data get lost.

I tried bunch of settings configuration i found online and also configure Firefox to let cookies but nothing works. Anyone familiar with same kind of issue? Thanks in advance.

What versions of Django and Python are you using? How are you running your project? (Are you using runserver in a development environment or are you using a production environment?)

What session engine are you using?

What do you mean by “that session data get lost”? Does the session cookie go away?

What are all the SESSION_ settings that you have in your settings.py file?

Django==5.0 and Python==3.10.12, I use runserver running Debug mode locally.

I don’t specify. So i assume session engine is default one.

Yes. Session cookie goes away. So it can’t retrieve logged in user data and redirect me to login page.

I don’t specify any SESSION_ related thing in my settings.py only sessions middleware and sessions app which they come default. Also after this problem occured i tried many SESSION_ things but none of them worked.

The next step would then be to examine what’s getting transfered for each request.

Look at the network tab in your browser’s developer tools to see what is being sent and received for each exchange, and identify which request causes the session id to be dropped from the cookies.

1 Like

Thanks Ken. I checked network requests both in Chrome and Firefox. I had a XMLHttpRequest in my script that caused to send request to login path somehow before any path in Firefox but not in Chrome. After i remove that script issue is gone.