//写入
string ip = Request.UserHostAddress;
HttpCookie cookie = new HttpCookie("CookieName");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("name");
sb.Append("#");
sb.Append(id.ToString());
sb.Append("#");
Random rnd = new Random();
int type = rnd.Next(0,9999);
cookie.Values.Add("Value",type.ToString());
cookie.Values.Add("Text",type.ToString());
cookie.Expires = DateTime.MaxValue;
Response.AppendCookie(cookie);
//读取
HttpCookie cookie = Request.Cookies["CookieName"];
int type = int.Parse(cookie.Values["Value"].ToString());
string cookieStr = Functions.DecryptCookie(cookie.Values["Text"].ToString(),type);
string [] myCookie = new String[10];
myCookie = cookieStr.Split('#');
name = myCookie[0];
string id = myCookie[1];
string now = myCookie[2];
string times = myCookie[3];
string ip = myCookie[4];
string seal = myCookie[5];