Search code examples
asp.netasp.net-mvcasp.net-identity

Asp.Net MVC Authentication Cookie Conflict


Suppose I Created two projects with name ABC and XYZ , and I am using MVC's Inbuilt Identity for Security. Then Problem is, If i login in app ABC I am also Logged In In XYZ . The Authentication Cookie created by ABC app is accepted by XYZ. How to resolve this conflict.


Solution

  • MVC5

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        CookieName = "Project1_ApplicationCookie",
        ...
    }
    

    MVC6

    services.ConfigureApplicationCookie(options => {
        options.Cookie.Name = "Project1_ApplicationCookie";
        ...
    });
    

    Rename "Project1" to something relevant and change it between projects