protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
HttpCookie UserInfo = new HttpCookie("UserInfo");
UserInfo.Value = "bdstjk";
Response.Cookies.Add(UserInfo);
}
}
protected void btnRemoveCookie_Click(object sender, EventArgs e)
{
Response.Cookies.Remove("UserInfo");
Response.Write("script type=\"text/javascript\">alert(\"删除Cookie成功!\");/script>");
}
protected void btnCheckCookie_Click(object sender, EventArgs e)
{
if (Request.Cookies["UserInfo"] != null)
{
Response.Write("Cookie存在,"+Request.Cookies["UserInfo"].Value);
}
else
{
Response.Write("Cookie不存在");
}
}