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.
Remarks. The FormsCookieName property value is set in the configuration file for an ASP.NET application by using the name attribute of the forms configuration element. The FormsCookieName is used to reference the cookie that stores the FormsAuthenticationTicket information.
The ASPXAUTH cookie is used to determine if a user is authenticated. As far as the location of the cookie, that depends on your browser. If you are using Firefox you can view the cookie by clicking on Tools -> Options -> Privacy. Then scroll down to the domain and expand it to see the cookie and its value.
The SetAuthCookie method adds a forms-authentication ticket to either the cookies collection or the URL if CookiesSupported is false . The forms-authentication ticket supplies forms-authentication information to the next request made by the browser.
FormsAuthenticationTicket(Int32, String, DateTime, DateTime, Boolean, String, String) Initializes a new instance of the FormsAuthenticationTicket class with cookie name, version, directory path, issue date, expiration date, persistence, and user-defined data.
You can adjust it in your web.config file:
<authentication mode="Forms"> <forms name=".CookieName" loginUrl="LoginPage.aspx" /> </authentication>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With