user3206213
user3206213

Reputation: 103

Is cookies shared between two applications on same host machine

I have two application hosted on my machine with urls as below.

"//mymachine:port1/appl"
"//mymachine:port2/app2"

Both App1 and app2 use same login credentials. My problem is that when user logs out of App2, app1 also seems to be logged out and redirects to login page. Is there some settings in IIS so that a logout in App2 does not affect App1.

Upvotes: 3

Views: 3544

Answers (3)

user3206213
user3206213

Reputation: 103

Finally solved the issue by setting different paths to forms authentication cookie.

In app1 set as

<authentication mode="Forms">
      <forms loginUrl="~/MyController/MyAction" timeout="60" path="/"/>
    </authentication>

In app2 set as

<authentication mode="Forms">
      <forms loginUrl="~/MyController/MyAction" timeout="60" path="/SomeOtherPath"/>
    </authentication>

Upvotes: 0

Mohamad Shiralizadeh
Mohamad Shiralizadeh

Reputation: 8765

Browser stores cookies base on Domain name and Path, if you pay attention to cookie tab of firebug you see that session cookies of localhost stores in localhost domain name. So two application have same cookies. but you can store application cookies on different path.

Response.Cookies.Add(new HttpCookie("Data")
{
    Value = "....",
    Path = "/app1"
});

Response.Cookies.Add(new HttpCookie("Data")
{
    Value = "....",
    Path = "/app2"
});

localhost:2000 localhost:2001

Upvotes: 2

dazzling kumar
dazzling kumar

Reputation: 604

if you use session for logins in both the application ,your problem will be solved

for example create session as

session["email"] = emailtextbox.text

create it in both the application and check the session in each and every form thats it

Upvotes: 0

Related Questions