how read cookie value using javascript created in Asp.net C# - Stack Overflow

I am using ASP MVC 2.0 , i want to set Cookie from my Controller and read it from java Script i there a

I am using ASP MVC 2.0 , i want to set Cookie from my Controller and read it from java Script i there any way to do so i have used following code in controller

HttpCookie ActiveTabs = new HttpCookie("tabs");
ActiveTabs.Values["top_navi_link"] = "ViewConference";
Response.Cookies.Add(ActiveTabs);

how to read it from java script.

I am using ASP MVC 2.0 , i want to set Cookie from my Controller and read it from java Script i there any way to do so i have used following code in controller

HttpCookie ActiveTabs = new HttpCookie("tabs");
ActiveTabs.Values["top_navi_link"] = "ViewConference";
Response.Cookies.Add(ActiveTabs);

how to read it from java script.

Share Improve this question edited Feb 13, 2012 at 13:32 Gaurav Mishra asked Feb 13, 2012 at 13:24 Gaurav MishraGaurav Mishra 711 silver badge5 bronze badges 4
  • 1 Use Google. w3schools./js/js_cookies.asp – CBusBus Commented Feb 13, 2012 at 13:26
  • 3 @SOliver, w3schools? Seriously? There are also w3fools – Darin Dimitrov Commented Feb 13, 2012 at 13:30
  • 1 @DarinDimitrov: Yes seriously; they provide a adequate solution to the OP's problem. w3fools are claiming that there is a lot of questionable content on the site, not that every item on it is wrong. – CBusBus Commented Feb 13, 2012 at 13:45
  • I agree with SOliver here. Most of W3Schools is good info, but there are quite a few bad ones. And the bulk of the "bad ones" are very nitpicky. – Darthg8r Commented Feb 13, 2012 at 14:46
Add a ment  | 

2 Answers 2

Reset to default 4

Use this jquery jquery-cookies.js which make it easy:

var cookiedata = $.cookie('top_navi_link');
<script type="text/javascript">
    alert(document.cookie);
</script>

There are also some jquery plugins such as jquery.cookie which might simplify this task.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744023545a4545291.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信