HttpCookie cookie = new HttpCookie("guid"); //創建
cookie.Values["id"] = “123456789”; //將“123456789”寫入id
HttpContext.Current.Response.AppendCookie(cookie); //保存
HttpCookie cookie = HttpContext.Current.Request.Cookies[“guid”]; //讀取
string id = cookie.Values["id"].ToString(); //id="123456789"
cookie.Expires 可以設置過期時間,一般不進行設置默認關閉瀏覽器后失效