'ASP.NET Core 6 - Cookie gets returned but not stored in browser

I am struggling with Cookie Authentication in Asp.Net Core 6.0

I have implemented and configured the Cookie Authentication and the problem I am facing is the following.

When sending POST request to the login Endpoint which is at <domain>/api/account/login the login returns a 200 OK response and the correct cookie.

However, the Cookie is not getting stored in the browser.

The Cookie Configurations

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
    {
      options.Cookie.Name = "Affito.Identity";
      options.Cookie.HttpOnly = true;
      options.Cookie.SecurePolicy = CookieSecurePolicy.None;
      options.Cookie.SameSite = (SameSiteMode) (-1);
      options.SlidingExpiration = true;
      options.Cookie.Domain = ".affito.ch";
      options.ExpireTimeSpan = TimeSpan.FromMinutes(3);
      options.Cookie.IsEssential = true;
    });

  services.Configure<CookiePolicyOptions>(options =>
  {
    options.MinimumSameSitePolicy = (SameSiteMode)(-1);
    options.HttpOnly = HttpOnlyPolicy.None;
    options.Secure = CookieSecurePolicy.None;
  });

since I have multiple subdomains that need to work with the same cookie I have the .domain attribute in options.Cookie.Domain.

This is the response from the Network Tab in the browser after sending the login request enter image description here

However, the Cookie is getting returned but it is not getting stored in the browser for future requests.

I am sending a simple fetch request from the React-App:

const response = await fetch(BASEURL + "/account/login", {
  method: "POST",
  body: JSON.stringify(loginData),
  headers: {
    "Content-Type": "application/json",
  },
});

console.log(response);

};

Am I missing something or why does it not store the cookie in the browser. I have consulted the docs but could not figure that out.

Swagger: When sending the request from swagger, it returns the same cookie and stores it correctly in the browser. enter image description here

I guessed it had something to do with the 'SameSite' Restriction that's why I took it out but it still does not work when sending the request from stage."domain"



Solution 1:[1]

pandas already implement BusinessHour and BusinessDay:

from pandas.tseries.offsets import BusinessDay
from pandas.tseries.offsets import BusinessHour
from dateutil import parser

myDate = parser.parse('Fri, 7 Jan 2022 17:00:00 +0000 (UTC)')
myWorkTime = BusinessDay(1) + BusinessHour(1)

print(myDate + myWorkTime)

This will print Timestamp('2022-01-11 10:00:00+0000', tz='tzutc()').

You can find a lot of tutorials over the internet (like this one for example)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 WildSiphon