无法读取“ASP.NET_SessionId” javascript中的cookie [英] unable to read "ASP.NET_SessionId" cookies in javascript
本文介绍了无法读取“ASP.NET_SessionId” javascript中的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在codebind的会话中存储了一些数据,因为
Hi ,I am storing some data in session in codebind as
protected void Page_Load(object sender, EventArgs e)
{
Session["kkk"]="kkk";
}
并尝试在javascript中读取此会话cookie ID
and trying to read this session cookie id in javascript as
<a href="#" önclick="myname()">
read cookie here
</a>
<script> function myname() {
alert(document.cookie);
} </script>
但它返回的空饼干?
请帮助
But its returning empty cookie ??
Please help
推荐答案
这是设计的。
会话cookie只是服务器用来将请求映射到a的随机标识符特定的会话对象。因此,它不是要从客户端读取,因此cookie设置了HttpOnly
标志。这是一件好事,因为它可以防止恶意脚本劫持你的会话。
即使你能阅读会话cookie,它也只是一个毫无意义的ID。存储在会话中的值将无法从您的脚本中获得。
This is by design.
The session cookie is just a random identifier which the server uses to map the request to a particular session object. As such, it isn't meant to be read from the client, so the cookie has theHttpOnly
flag set. This is a good thing, because it prevents malicious script from hijacking your session.
Even if you could read the session cookie, it's just a meaningless ID. Values stored within the session will not be available from your script.
这篇关于无法读取“ASP.NET_SessionId” javascript中的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文