为何取不到cookie的值
protectedvoidbtnAdd_Click(objectsender,EventArgse){HttpCookiecookie1=newHttpCookie("n...
protected void btnAdd_Click(object sender, EventArgs e)
{
HttpCookie cookie1 = new HttpCookie("name");
Response.Cookies["name"].Value = txtAdd.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
}
protected void btnShow_Click(object sender, EventArgs e)
{
HttpCookie cookie2 = Request.Cookies["name"];
lblShow.Text = cookie2.Value;
}
} 展开
{
HttpCookie cookie1 = new HttpCookie("name");
Response.Cookies["name"].Value = txtAdd.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
}
protected void btnShow_Click(object sender, EventArgs e)
{
HttpCookie cookie2 = Request.Cookies["name"];
lblShow.Text = cookie2.Value;
}
} 展开
2个回答
展开全部
HttpCookie cookie1 = new HttpCookie("name");
Response.Cookies["name"].Value = txtAdd.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
改为
cookie1.Value = txtAdd.Text;
cookie1.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
Response.Cookies["name"].Value = txtAdd.Text;
Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
改为
cookie1.Value = txtAdd.Text;
cookie1.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie1);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询