asp.net5 操作Cookie

写入Cookie

var CookieOption = new CookieOptions();
CookieOption.Path = "/";

//on localhost, Domain value is not needed !!
CookieOption.Domain = "";

CookieOption.Expires = DateTime.Now.AddHours(1);
CookieOption.HttpOnly = true;
           
//set cookie
Context.Response.Cookies.Append("TestCookie", "Testing", CookieOption);

读取Cookie

string testCookie = Context.Request.Cookies.Get("TestCookie");

 

posted @ 2016-09-06 10:36  KID  阅读(554)  评论(0编辑  收藏  举报