title: Unable to set a cookie in Azure Functions
body: <p>I have a Azure function named &quot;Login&quot; in which I am authenticating users against my database. If its a valid user I want to set a cookie and send to browser. I am using the following code:</p>
  <pre><code>CookieOptions option = new CookieOptions();
                  option.Expires = DateTime.Now.AddDays(3);
                  option.HttpOnly = true;
  
                  req.HttpContext.Response.Cookies.Append(&quot;KTAuth&quot;, User.UserId.ToString(), option);
  </code></pre>
  <p>The problem I am facing is that I am unable to read this cookie in JavaScript. I used the following code in JavaScript.</p>
  <pre><code>function getCookie(cname) {
  var name = cname + &quot;=&quot;;
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for (var i = 0; i &lt; ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0) == ' ') {
          c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
          return c.substring(name.length, c.length);
      }
  }
  return &quot;&quot;;
  }
  </code></pre>
  <p>Any suggestions/ pointers here will help.</p>