I am trying to set a cookie with Expires date:
response.Cookies.Append("theKey", value, new CookieOptions() { Expires = DateTime.Now.AddMonths(12) });
the cookie is stored in the browser but is not sent in a subsequent cross-site web request.
When I try set the cookie without the Expires
date, the cookie is sent, but it is stored in the browser only while the browser is open (session cookie).
It is a cross-site request. The javascript code that calls the function is:
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);
Is there a way to send a cookie containing Expires
date in a cross-site request?
Both the client web app and the function app (that attempts to set the cookie) use https.
This is the HTTP response setting the cookie with expiration date: