0

Well , I have an ASP.NET MVC 3 RAZOR PAGE , and I declare a cookie from server-side:

@{
Request.Cookie["Name1"].Value = "Value1";
}

and, when I want to use and change it at client side , it working dubious

<script type = "text/javascript"> 
var e
 function aa(c) { $.cookie("Name1", c); }

 function bb() { e = $.cookie("Name1"); }

</script>

It`s something wrong ?

4

1 に答える 1

2

リクエストではなく、レスポンスでCookieを設定する必要があると確信しています:

HttpCookie myCookie = new HttpCookie(CookieName);
myCookie.Values["UserId"] = user.UserId.ToString();
myCookie.Values["LastVisit"] = DateTime.Now.ToString();
myCookie.Expires = DateTime.Now.AddDays(365);
HttpContext.Current.Response.Cookies.Add(myCookie);
于 2013-11-13T15:03:10.497 に答える