Cookieの書き込み †
ただ書き込む場合 †
this.HttpContext.Response.Cookies.Append("TestKey1", "TestValue1");
this.HttpContext.Response.Cookies.Append("TestKey2", "TestValue2");
Cookiesの詳細オプション設定して書き込み †
- このオプションを設定すると「samesite=lax」が追加される
- この属性があるとクロスドメインアクセスしたときに当該Cookieを送信しなくなる
var cOptions = new CookieOptions() {
HttpOnly = true,
Expires = new DateTimeOffset(DateTime.Now.AddDays(2))
};
this.HttpContext.Response.Cookies.Append(cKey,cValue,cOptions);
Cookieの読み込み †
Cookieの削除 †
this.HttpContext.Response.Cookies.Delete(cKey);