Sharing Cookies Between Two ASP.NET Core Applications

This is documented at Sharing cookies among apps with ASP.NET and ASP.NET Core. There is also a Cookie Sharing App Sample available.

In order to share cookies, you create a DataProtectionProvider in each app and using a common/shared set of keys between the apps.

.AddCookie(options =>
    options.Cookie.Name = ".SharedCookie";
    options.Cookie.Domain = "";
    options.DataProtectionProvider =
        DataProtectionProvider.Create(new DirectoryInfo("path-tokeys"));

Leave a Comment