我登录到 django 管理员。当我打开firebug JS 控制台并尝试打印 cookie 时,document.cookie
我只得到csrftoken
cookie。但是当我打开 Firefox 首选项 > 隐私 > 删除 cookie... 时,我可以看到sessionid
cookie。
如何在客户端获得它?
我登录到 django 管理员。当我打开firebug JS 控制台并尝试打印 cookie 时,document.cookie
我只得到csrftoken
cookie。但是当我打开 Firefox 首选项 > 隐私 > 删除 cookie... 时,我可以看到sessionid
cookie。
如何在客户端获得它?
您无法访问会话 cookie,因为它默认设置为 HTTPOnly。(您可以使用 Firebug 看到它(Resources->Cookies->sessionid 的 HTTP 列已选中))
从文档复制:
SESSION_COOKIE_HTTPONLY Default: True Whether to use HTTPOnly flag on the session cookie. If this is set to True, client-side JavaScript will not to be able to access the session cookie.
SESSION_COOKIE_HTTPONLY = False
如果您真的想从客户端代码访问它,您可以在您的 settings.py 中设置:尽管如此,这不是推荐的做法。