Can I change the FormsAuthentication cookie name?

2019-01-13 17:11发布

问题:

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.

回答1:

You can adjust it in your web.config file:

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


回答2:

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>