HttpCookie Cookie = new HttpCookie("Shop");
//服务端存入Cookie前先进行编码
Cookie.Values.Add(ShopId,HttpUtility.UrlEncode(ShopInformation, System.Text.Encoding.Default));
Cookie.Expires = DateTime.Now.AddMinutes(20);
Response.Cookies.Add(Cookie);
//客户端读取 按编码的格式进行解码
var Shop = Request.Cookies["Shop"][Key].ToString();
Shop = HttpUtility.UrlDecode(Shop,System.Text.Encoding.Default);
var ShopData = Shop.Split(‘,‘);
时间: 2024-10-31 06:56:24