asp.net中关于Cookies
大家先看看我这代码:
if (rmbUser.Checked)//记住密码
{
HttpCookie cook = new HttpCookie ("Cookie");
cook.Values.Add ("name", model.LoginId);
cook.Values.Add ("pwd", pwd.Text);
cook.Expires.Add (TimeSpan.FromDays (7));
Response.AppendCookie (cook);
}
else
{
HttpCookie ck = Request.Cookies["Cookie"];
if (ck != null)
{
ck.Expires = DateTime.Now.AddDays (-1);
Response.AppendCookie (ck);
}
}
if (Request.Cookies["Cookie"] != null)
{
HttpCookie cookie=Request.Cookies["Cookie"] ;
name.Text = cookie.Values["name"];
pwd.Attributes.Add ("value", cookie.Values["pwd"]);
rmbUser.Checked = true;
}