1

Imagine when you create a new MVC4 Project and you start registering an account using SimpleMembership and you logged using Remember Me checkbox.

Now, when you create another MVC 4 Project, the application tries to loggin using the previous account, although throws an error because it does not exist. I mean, if a do a login in a web page, the another one uses the same account.

How can avoid this, I guess has to be with ForgeryTokens or something like that

tereško
  • 58,060
  • 25
  • 98
  • 150
Darf Zon
  • 6,268
  • 20
  • 90
  • 149

3 Answers3

1

Customize the name of the cookie so that it's unique per application.

<authentication mode="Forms">
    <!-- **Defaults** timeout="30" slidingExpiration="true" -->
    <forms name=".MyApplication" defaultUrl="~/" loginUrl="~/LogIn"  />
</authentication>
Nick Albrecht
  • 16,607
  • 10
  • 66
  • 101
0

if you are using a single sign on mechanism then it is a exceptionable scenario but if you do not wish to allow the same authentication with same account to another website then make sure the web.config file for both projects must have a different machine keys.

Also, this is happened because of cookies on your machine is set to true, to create cookies file and allow access to other project using this cookies details.

< Authentication />

Softtech
  • 112
  • 6
0

It happens because when the web page is served the browser sees localhost as the domain name. It saves the cookie for localhost.

When you host another website on the same server with localhost, then the browser sends the same cookie again.

If you are using the same cookie name in both the applications, then the system will try to think that the user is already authenticated and you will get the error.

You can change the cookie name in web.config file.

Read this:

Can I change the FormsAuthentication cookie name?

Community
  • 1
  • 1
Suneel Dixit
  • 889
  • 2
  • 10
  • 17