I have a website which has subdomains such as ali.sarahah.com but if a user logs in from www.sarahah.com then goes to ali.sarahah.com the session is not saved. After searching I added the following in Startup.cs
:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieDomain = ".sarahah.com"
});
I found out that .AspNetCore.Identity.Application cookie domain is still showing the subdomain and not the the domain and that session problem is still there.
Am I doing something wrong?
I think you need to remove the leading .
in the domain assignment as detailed in this GitHub issue:
app.UseCookieAuthentication(
new CookieAuthenticationOptions
{
// Note that there is no leading .
CookieDomain = "sarahah.com",
CookieSecure = CookieSecurePolicy.None
});
See the CookieAuthenticationOptions
for the various properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With