Django generates a new session ID on every API call

1.1k views Asked by At

I have a Django back-end that feeds a front-end through a REST API. I am facing an issue with Django generating a new session ID on every API call.

I am testing with Chrome and I noticed that the sessionid cookie is only created if I run the webserver locally. The problem occurs when I go online.

Here is a couple of useful settings to help troubleshooting:

SESSION_SAVE_EVERY_REQUEST = True
MIDDLEWARE_CLASSES = (
    ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    ...
}
INSTALLED_APPS = (
    ...
    'django.contrib.sessions',
    ...
)
if not local:
    SESSION_COOKIE_DOMAIN = '.my-domain.com'

Any setting that was not mentioned above should be considered to be set to the default value (Django 1.6).

0

There are 0 answers