最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Django: Cannot access sessionid cookie using Javascript - Stack Overflow

programmeradmin2浏览0评论

I tried using several mechanisms, including the jquery cookie plugin. When I try to read this cookie, I always get an empty result. Chrome's Developer Console shows that the sessionid cookie is indeed set. However, there's a checkmark for the HTTP column for that cookie, which is different than the other cookies. I'm developing on my localhost, if that makes a difference.

I tried using several mechanisms, including the jquery cookie plugin. When I try to read this cookie, I always get an empty result. Chrome's Developer Console shows that the sessionid cookie is indeed set. However, there's a checkmark for the HTTP column for that cookie, which is different than the other cookies. I'm developing on my localhost, if that makes a difference.

Share Improve this question asked Jul 4, 2013 at 18:37 lairtechlairtech 2,4274 gold badges29 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 16

It's a HTTP-only cookie; they cannot be read by JavaScript.

http://en.wikipedia/wiki/HTTP_cookie#Secure_and_HttpOnly

It's explained in the documentation about sessions:

https://docs.djangoproject./en/dev/topics/http/sessions/#using-cookie-based-sessions

The behavior can be changed by setting SESSION_COOKIE_HTTPONLY to false (but that is not remended; see link above).

发布评论

评论列表(0)

  1. 暂无评论