加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 在javascript中读取cookie

发布时间:2020-12-15 23:57:30 所属栏目:asp.Net 来源:网络整理
导读:这是我的asp代码,可以在Javascript中完成吗? HttpCookie cookie = this.Request.Cookies["Votes"];if (cookie != null) if (cookie.Values.Get(id.ToString()) == "true") return true;return false; 解决方法 function readTheCookie(the_info){// load th
这是我的asp代码,可以在Javascript中完成吗?
HttpCookie cookie = this.Request.Cookies["Votes"];
if (cookie != null)
    if (cookie.Values.Get(id.ToString()) == "true")  return true;
return false;

解决方法

function readTheCookie(the_info)
{
// load the cookie into a variable and unescape it

 var the_cookie = document.cookie;
 var the_cookie = unescape(the_cookie);

// separate the values from the cookie name

 var broken_cookie = the_cookie.split("some parameter"); // parameter depends on how the cookie is stored
 var the_values = broken_cookie["some index"]; // index of the value that you want
}

这些都是阅读cookie的所有部分,您可以使用此片段来实现您想要的效果.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读