无法访问Cookie值 [英] Unable to access cookie value
问题描述
在清除浏览器历史记录后,我转到以下URL: http://indianvisa -bangladesh.nic.in/visa/index.html
After clearing my browser history when I go to this URL: http://indianvisa-bangladesh.nic.in/visa/index.html
然后我点击获取约会"绿色链接,该链接将带我们到 http://indianvisa-bangladesh.nic.in/visa/Appointment_Login.jsp
then I click on "Get Appointment" green link which takes us to http://indianvisa-bangladesh.nic.in/visa/Appointment_Login.jsp
此处设置了JSESSIONID
cookie.我在Firefox/Chrome开发人员工具中都可以看到此cookie,但是无法在控制台中使用document.cookie
来访问它.
Here it sets a JSESSIONID
cookie. I can see this cookie in both Firefox/Chrome developer tools but can't access it using document.cookie
in console.
当我键入document.cookie;
时,它显示为空字符串.
When I type document.cookie;
it shows empty string.
如何打印?
另外,此JSESSIONID cookie的Path
值为"/visa"
Also this JSESSIONID cookie has Path
value of "/visa"
推荐答案
The reason behind you can't read this cookie is because it is HTTPOnly Cookie, So if you are developer then you can set it easily false in your code when you are creating it. otherwise you can't get it using javascript. This is specifcally a feature rather than a bug provided by all major browsers.
有关HTTP标志的信息,请参见下文
See below for HTTP flag
更多参考资料: SOQuestion1 , SOQuestion2 , SOQuestion3
More references: SOQuestion1, SOQuestion2, SOQuestion3
这篇关于无法访问Cookie值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!