我正在尝试使用过期日期设置 cookie:
response.Cookies.Append("theKey", value, new CookieOptions() { Expires = DateTime.Now.AddMonths(12) });
cookie 存储在浏览器中,但不会在后续的跨站点 Web 请求中发送。
当我尝试设置不带Expires日期的 cookie 时,会发送 cookie,但它仅在浏览器打开时存储在浏览器中(会话 cookie)。
这是一个跨站点请求。调用该函数的 javascript 代码是:
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, true);
xmlHttp.withCredentials = true;
xmlHttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
//console.log(this.responseText);
}
};
xmlHttp.send(null);
Expires有没有办法在跨站点请求中发送包含日期的 cookie ?
客户端 Web 应用和函数应用(尝试设置 cookie)都使用 https。
这是设置带有过期日期的 cookie 的 HTTP 响应:
