0
votes

I am using multiple subdomain for my application. For example my primary domain is example.com, the user is logging in on that domain. Now the user navigates to user.example.com, what i trying to achieve is that the same cookie gets used for all subdomains and the primary domain.

Reading a few items i implemented the below:-

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
     Response.Cookies["ASP.NET_SessionId"].Domain = ".example.com"; 
}

Now using a cookie editor, i inspected the cookies being created when i'm logging in on example.com, an ASP.NET_SessionId is being created which is good. However if i now make a call from user.example.com, the ASP.NET_SessionId is not being set from my browser before the request goes to the server.

Any advice on how to achieve the above ?

1

1 Answers

0
votes

Put <httpCookies domain=".example.com" /> in your web.config