Multiple applications using the same login database, registering each other

I installed two ASP.NET applications on the computer, their files in the web.config file contain the same applicationName value in the AspNetSqlMembershipProvider element, so they share users and roles.

Task sequence:

  • user is registered in application A,
  • opens a new tab in the browser
  • recorded in Appendix B,
  • his entry into Appendix A is completed

and vice versa.

Should I use a different approach for sharing login information between two applications?

+7
login asp.net-membership
source share
2 answers

The problem is that the same cookie is used to authenticate two different logins.

The solution from what I understand is to give different cookie names for different logins, so one cookie does not overwrite another.

Perhaps the solution is on web.config.

In configuration

Change the name value to something else in your two applications if you have the same domain and are running in different directories / applications, or change the domain value that was also used to store the cookie.

<authentication mode="Forms"> <forms name=".CookieSuffix" domain="yoururl.com" ... /> </authentication> 

For example, on two different websites in your applications, put on application 1: name = ". App1"
on application 2: name = ". app2"

Or on app 1: domain = "app1.yoururl.com"
on application 2: domain = "app2.yoururl.com"
if you are separating your apps, based on the url, or even trying to use some similar hints.

The cookie is saved using the cookie name in the domain name, so these are 2 values ​​that you should try to separate from them.

Details on setting up the form can be found here: http://msdn.microsoft.com/en-us/library/aa480476.aspx

Manual Entry

If you have the option to manually log in, the solution is in this function

 FormsAuthentication.GetAuthCookie(cUserName, false, "cookiePath"); FormsAuthentication.SetAuthCookie(cUserName, false, "cookiePath"); 

You just need to use a different cookiePath, but you have to change a lot of points in your program and capture the login, log out and authenticate.

Hope this helps you.

+15
source share

You should check out this tutorial.

Scroll down to the "Separate custom store in apps" section. It says that you can use the same user repository for multiple applications.

0
source share

All Articles