tags:

views:

1311

answers:

3

I'm aware that you can get session variables using request.session['variable_name'], but there doesn't seem to be a way to grab the sessionid as a variable in a similar way. Is this documented anywhere? I can't find it. Thanks for your help!

+4  A: 

Django sessions save their key in a cookie. At least its middleware extracts it like this:

from django.conf import settings
session_key = request.COOKIES[settings.SESSION_COOKIE_NAME]
che
A: 

request.COOKIES['sessionid']

Harold
+12  A: 

Much simpler:

request.session.session_key

dalore