if (Request.Cookies["UserInfo"] == null)
{
//创建Cookie 并命名
HttpCookie cookietwo = new HttpCookie("UserInfo");
// cookietwo.Name = "UserInfo";
//Cookie为一年有效期
cookietwo.Expires = DateTime.Today.AddDays(360);
//设置Cookie对应键值
cookietwo.Values["username"] = txtUserName.Text;
cookietwo.Values["pwd"] = txtPassword.Text;
// CookieHelp.CookieHelper.AddCookie(cookietwo);
// 用Response添加到Cookie中
Response.Cookies.Add(cookietwo);
}
//用Request获取到客户端Cookie 判断是否为空
if (Request.Cookies["UserInfo"] != null)
{
//读取Cookie 键值
txtUserName.Text = Request.Cookies["UserInfo"]["username"].ToString();
txtPassword.Text = Request.Cookies["UserInfo"]["pwd"].ToString();
}