asp.net5 操做Cookie

寫入Cookiecookie

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);

讀取Cookiespa

string testCookie = Context.Request.Cookies.Get("TestCookie");
相關文章
相關標籤/搜索