Joshua Wieczorek
Joshua Wieczorek

Reputation: 735

Multiple .NET Applications Share Authentication

I have 2 mvc .net applications, 1 is written in vb and the other in c#.

The are structured as follows:

The user initially logs into the /site app and has the ability to navigate to the root site.

My web.config application > authentication is as follows:

<forms 
name="SITECOOKIE" 
protection="All"  
path="/" 
domain="app1.example.com" 
timeout="15" />  

My issue is, the user logs into the http://app1.example.com/ site app where the Login controller takes care of the authentication process and sets the "SITECOOKIE". However, when navigating to the root site, http://app1.example.com, the root app cannot access or see the cookie "SITECOOKIE".

What can I do so the root app has access to the cookie "SITECOOKIE"?

Upvotes: 0

Views: 233

Answers (1)

Win
Win

Reputation: 62300

You just need to set domain to example.com, if you want to share cookie between two websites.

<forms 
   name="SITECOOKIE" 
   protection="All"  
   path="/" 
   domain="example.com" 
   timeout="15" />  

Ensure you set same machinekey in both web.config file.

Upvotes: 1

Related Questions