Can I change the FormsAuthentication cookie name?

asp.netCookiesForms Authentication

asp.net Problem Overview


Can I change the FormsAuthentication cookie name?

If yes, How?

The problem which I've got is that when I have two web applications are deployed in the same domain then when anyone is logged in then the second one will be automatically logged out because they use the same Authentication's cookie name.

asp.net Solutions


Solution 1 - asp.net

You can adjust it in your web.config file:

<authentication mode="Forms">
  <forms name=".CookieName" loginUrl="LoginPage.aspx" />
</authentication>

Solution 2 - asp.net

Yes you can specify the cookie name in web.config on forms element under authentication element.

<authentication mode="Forms">
    <forms name="RoleBasedAuthenticationCookiename" loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx">
    </forms>
</authentication>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFrench BoyView Question on Stackoverflow
Solution 1 - asp.nettwoflowerView Answer on Stackoverflow
Solution 2 - asp.netWaqas RajaView Answer on Stackoverflow