1

I have a primary web app with authentication on example.com, and I have a secondary app with authentication on subdomain.example.com

I want the 2nd app to be integrated with the first one. So once a user registers and logs in, s/he doesn't have to register/log in again.

It is possible to send a post request, but this won't generate the cookies in user's browser...

How can I do that?

Thanks

1 Answer 1

1

You're able to set a cookie so that it works on all subdomains (www, subdomain, etc.). See Basics of Cookies in ASP.NET:

By default, cookies are associated with a specific domain. For example, if your site is www.contoso.com, the cookies you write are sent to the server when users request any page from that site. (Except for cookies with a specific path value, as I explained in the section immediately preceding.)

You can also use the Domain property to create a cookie that can be shared among multiple subdomains. For example, set the domain as follows:

Response.Cookies("domain").Value = DateTime.Now.ToString
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "contoso.com"

The cookie will then be available to the primary domain as well as to sales.contoso.com and support.contoso.com.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.