手动添加Cookie

 

Controller设置Cookie第一种方式:
写:Response.SetCookie(new HttpCookie("mycookie"){ Value="1234" });
读:Request.Cookies["mycookie"].Value;

Controller设置Cookie第二种方式:
写:Response.Cookies.Add(new HttpCookie("Customer") { Value = Server.UrlEncode(source.Result.Data), Expires = DateTime.Now.AddDays(300) });
读:string customer = Server.UrlDecode(Request.Cookies["Customer"].Value);

 

posted on 2017-11-09 11:10  D-Z-K  阅读(908)  评论(0编辑  收藏  举报

导航