Search code examples
asp.net-mvccookiesazure-ad-b2cowin.security

Azure AD B2C domain cookie


I have a web app which runs under service.domain.de. For authentication in this app I use Azure AD B2C. In the azure security cookie is for the domain service.domain.de . What can I do to get the security cookie for the domain .domain.de? So with the domain .domain.de the cookie is for the domain.de and all subdomains. The service I wrote in ASP.Net and used Microsoft.Owin.Security library (OpenId).


Solution

  • When you add CookieAuthentication, you can control the domain via CookieAuthenticationOptions' CookieDomain like so:

    app.UseCookieAuthentication(new CookieAuthenticationOptions {
      CookieDomain = "domain.de"
    });