In Django, how can I find out the request.session sessionid and use it as a variable?

前端 未结 8 873
借酒劲吻你
借酒劲吻你 2020-12-13 03:08

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

8条回答
  •  半阙折子戏
    2020-12-13 03:46

    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]
    

提交回复
热议问题