C#C
C#4y ago
Sebastian

Cookies not being set on localhost

Hi!

I am setting my cookie on my ASP.NET Core backend:
CookieOptions cookieOptions = new CookieOptions
{
    HttpOnly = true,
    Expires = DateTime.UtcNow.AddMinutes(60000)
};

this.Response.Cookies.Append("PT", "authtokenhere", cookieOptions);


I am running create-react-app on my frontend and I am receiving this cookie in response in the headers. The problem is that the cookie is not being set into cookies when inspecting it in browser and is also not being sent in next API requests.

Frontend: http://localhost:3001/login
  • where request is being sent from
    Backend: http://localhost:39500/account/login
    • API
tried several settings for the cookie, playing with SameSite and Secure but nothing seems to be working?
How can I make cookies work when working on localhost?
Was this page helpful?