C#服务器端读写cookie

通过js读写cookie,大家都知道,在服务器端,怎么读写cookie呢?

读cookie:

        string cookie = context.Request.Cookies["guid"] == null ? "" : context.Request.Cookies["guid"].Value as string;

写cookie:

         string cookie = Guid.NewGuid().ToString();
         HttpCookie objCookie = new HttpCookie("guid", cookie);
         objCookie.Expires = DateTime.MaxValue;
         context.Response.Cookies.Add(objCookie);

 

keyword:服务器端读写cookie,HttpCookie

   

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页