虽然不常用,不过还是要记录一下。
以后要多学会用Cookie保存用户信息。
public void SaveCookie()
{
// Use this line when you want to save a cookie
Response.Cookies["MyCookieName"].Value = "MyCookieValue";
// How long will cookie exist on client hard disk
Response.Cookies["MyCookieName"].Expires = DateTime.Now.AddDays(1);
// To add multiple key/value pairs in single cookie
Response.Cookies["VisitorData"]["FirstName"] = "Richard";
Response.Cookies["VisitorData"]["LastVisit"] = DateTime.Now.ToString();
}
public void ReadCookie()
{
string MyCookieValue;
// We need to perform this check first, to avoid null exception
// if cookie not exists
if (Request.Cookies["MyCookieName"] != null)
MyCookieValue = Request.Cookies["MyCookieName"].Value;
}
public void ClearCookie()
{
// First check if cookie exists
if (Request.Cookies["MyCookieName"] != null)
{
// Set its expiration time somewhere in the past
Response.Cookies["MyCookieName"].Expires = DateTime.Now.AddDays(-1);
}
}




,
Thank you
Bottomless
Hi there,
blog.bowenjia.com to GoogleReader!
Thank you
Boldy