Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net membership login issue

I am trying to run two web application using the same ASP.NET membership provider database that comes with MVC3. So two web app runs side by side and they both has the same connection to the same membership databse. The problem now is, I can only login at one app and get automatically log out at the other. However, the feature I want is, if I log into either one, I get automatically log into the other.

I was wondering what the trick is to enable this feature.

thanks a lot

like image 503
Frank Avatar asked Oct 11 '22 02:10

Frank


1 Answers

If you are using Forms Authentication users are tracked with cookies. Cookies are by default restricted only to the application that emitted them. And because of this the other application cannot see the authentication cookie created by the first. So for example if you have the two applications hosted respectively on foo.example.com and bar.example.com you could set the domain property of the cookie in web.config of both applications to example.com:

<forms
    loginUrl="/login/index.mcp"
    requireSSL="true"
    protection="All"
    timeout="120"
    domain="example.com"
/>

This way the cookie will be shared among those two applications and you will be able to achieve Single Sign On.

like image 196
Darin Dimitrov Avatar answered Oct 20 '22 15:10

Darin Dimitrov