title: Sharing Cookies Between Two ASP.NET Core Applications
body: <p>I'm using <a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.WsFederation" rel="noreferrer">WsFederation</a> in two separate ASP.NET Core projects.</p>
  
  <p>Each project has the following in <code>Startup.cs</code></p>
  
  <pre><code>services.AddAuthentication(sharedOptions =&gt;
  {
      sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
  })
  .AddWsFederation(options =&gt;
  {
      options.Wtrealm = Configuration["Wtrealm"];
      options.MetadataAddress = "http://example.com/metadata.xml";
      options.SkipUnrecognizedRequests = true;
      options.RequireHttpsMetadata = false;
      options.UseTokenLifetime = false;
  })
  .AddCookie(options =&gt;
  {
      options.Cookie.Name = "MySharedCookie";
      options.Cookie.Path = "/";
      options.Cookie.Domain = ".dev.example.com";
  });
  </code></pre>
  
  <p>I load project #1 in the browser and I get my cookie:</p>
  
  <p><a href="https://i.stack.imgur.com/tWbTt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tWbTt.png" alt="enter image description here"></a></p>
  
  <p>I then navigate to project #2 on the same sub domain. However, project #2 doesn't recognize <code>MySharedCookie</code> and re-authenticates. I get a new cookie with the same name but a different value:</p>
  
  <p><a href="https://i.stack.imgur.com/2PBl4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2PBl4.png" alt="enter image description here"></a></p>
  
  <p>Is what I'm trying to do possible in ASP.NET Core? Is there a way in ASP.NET Core I can share project #1's cookie with project #2?</p>