手动添加Cookie

Posted 我是谁的谁

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了手动添加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);

 

以上是关于手动添加Cookie的主要内容,如果未能解决你的问题,请参考以下文章