Search code examples
pythondjangorestdjango-1.6

Django no sessionid in cookie


Im using Mongo Engine/REST Framework with Django 1.6.

All I need is for the client to get a sessionid when he hits one of the views. However at the moment no sessionid is present in the cookie.

views.py

@csrf_exempt
def updateInput(request):
    return HttpResponse("view has been hit")

settings.py

MIDDLEWARE_CLASSES = Common.MIDDLEWARE_CLASSES + ('django.contrib.sessions.middleware.SessionMiddleware',)
INSTALLED_APPS += ('django.contrib.sessions',)

SESSION_ENGINE = 'mongoengine.django.sessions'
SESSION_SERIALIZER = 'mongoengine.django.sessions.BSONSerializer'

DJANGO_APPS = (
    'django.contrib.sessions',
)

Any ideas ?


Solution

  • According to the Django docs, a user has no session until it is necessary:

    Django only sends a cookie if it needs to. If you don’t set any session data, it won’t send a session cookie.

    You need to set some session data, then you will find the sessionid in the cookie.