Cookies 记不住信息是什么原因?

yudianbuding yudianbuding 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
cs: private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["web"] != null)
{
this.textfield.Value = Request.Cookies["userid"].Value;
}
}
}

protected void Button1_Click(object sender, ImageClickEventArgs e)
{
if (this.CheckBox1.Checked == true)
{
HttpCookie cookieinfo = new HttpCookie("web");
cookieinfo.Values.Clear();
cookieinfo["userid"] = this.textfield.Value.Trim();
cookieinfo.Expires = DateTime.Today.AddDays(30);
Response.Cookies.Add(cookieinfo);
}
}

断点跟踪后发现,首次登陆后确实执行了Button1_Click里的内容,但是二次登录后Request.Cookies["web"] 的值却 null,哪里出了问题?
...全文
评论 9
收藏 已收藏
分享
返回顶部
yudianbuding
.NET社区 62,275 成员 668,968 内容