azurecookiesazure-function-apphttpresponsemessage

Client fails to show cookie sent by Azure Function App in browser storage


I have a function app that sets a cookie when reached:

[FunctionName("SendCookie")]
        public async Task<HttpResponseMessage> SendCookie([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post","head", Route = null)] HttpRequest req, ILogger log)
        {
            var resp = new HttpResponseMessage();
            var cookie = new CookieHeaderValue("cookieKey", "cookieValue");
            cookie.Expires = DateTimeOffset.Now.AddDays(1);
            cookie.Domain = "https://azurefunctionapp.azurewebsites.net";
            cookie.Path = "/";
            resp.Headers.AddCookies(new CookieHeaderValue[] {cookie});
            return resp;
        }

I can see in Fiddler the cookie is sent along with ARRAfinity. But I don't see it on firefox's browser storage: enter image description here

Can someone share some guidance as to what i'm missing please?

thank you for your help


Solution

  • For this problem, you just need to remove cookie.Domain = "https://azurefunctionapp.azurewebsites.net";.

    I test it in my side with the same code with yours'(but without cookie.Domain)

    enter image description here

    And the result show as below:

    enter image description here

    Or you can also set the domain as cookie.Domain = "azurefunctionapp.azurewebsites.net";(just remove the https://), it will also work fine.