Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 263
felix001 Avatar asked Oct 16 '25 17:10

felix001


1 Answers

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.

like image 163
Martijn Arts Avatar answered Oct 18 '25 06:10

Martijn Arts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!