Nilay Sangani
Nilay Sangani

Reputation: 1

Session ID Returns None After Setting Session Data in Django with React Frontend

I'm working on a Django backend with a React frontend and using sessions to manage user authentication. After successfully logging in a user, I'm setting session data (e.g., user_id, name, email, etc.), but the session ID is returning as None despite the session data being correctly stored.

I've configured SESSION_ENGINE to use the database and set SESSION_SAVE_EVERY_REQUEST = True. CORS headers are properly configured with CORS_ALLOW_CREDENTIALS = True. Despite these settings, the session ID isn't being generated or returned correctly, which is causing issues with session management on the client side. How can I resolve this issue and ensure the session ID is properly generated and accessible after login?(https://i.sstatic.net/EawnCfZP.png)

I configured Django's session settings to use database-backed sessions, set SESSION_SAVE_EVERY_REQUEST = True, and enabled CORS with credentials. I expected the session ID to be generated and returned after a user logs in, allowing for proper session management. However, the session ID is returning as None, even though the session data is correctly stored and accessible. I’ve also verified that CORS and session settings are properly configured but still face the issue.enter image description here

Upvotes: 0

Views: 36

Answers (0)

Related Questions