Sharing login cookie between applications. ASP.NET Core
<p>What is the correct way to share the login cookie with an asp.net core application?</p>

<p>I've got a single application running behind multiple subdomains i.e :</p>

<ul>
<li>site1.mydomain.com</li>
<li>site2.mydomain.com</li>
</ul>

<p>and I can't get the authentication to persist across both.</p>

<p>I have the startup.cs configured in the following manner and this allows me to authenticate via google : </p>

<pre><code>app.UseIdentity();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
    LoginPath = new PathString("/account/login"),
    AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
    CookieDomain = ".mydomain.com",
    CookieName = "AuthenticationCookie"
});

app.UseGoogleAuthentication(options =&gt;
{
    options.ClientId = "xxx";
    options.ClientSecret = "xxx";
});
</code></pre>

<p>I also believe I correctly setup the data protection services because I currently have the site running in multiple docker containers and the application can successfully load balance.</p>

<p>What is confusing me is when I inspect the cookies set by the authentication process it always has the site1.mydomain.com logged against the authentication cookie and not .mydomain.</p>

<p>It's like the cookiedomain is being ignored during the authentication process.</p>

<p>Any pointers would be gratefully received.</p>