Response.Cookies["alertsCookie"]
给了我一块空白饼干。
我制作了两个 cookie,因为我不知道如何在路径中读取 cookie,所以我决定将它们写入两个位置(页面路径和 /)
代码隐藏:
HttpCookie seenAlertsCookie = Response.Cookies["alertsCookie"];
JavaScript (jQuery):
var cookie = $.cookie("alertsCookie");
alert(cookie);
if (cookie == null) {
$.cookie('alertsCookie', alertGuid, { expires: 7300, path: '/' });
$.cookie('alertsCookie', alertGuid, 7300);
}
else {
var cookieVal = cookie + '|';
cookieVal = cookieVal + alertGuid;
$.cookie('alertsCookie', cookieVal, { expires: 7300, path: '/' });
$.cookie('alertsCookie', cookieVal, 7300);
}