Form Authentication cookie
-
Hi, i am using Form Authentication in my asp.net appication. It creates a persistent cookie named Cookie1 in cookies folder at my system. I want to change/set the Name of this cookie to Cookie2 on the click of a button from page.How can i do that ? (Q: Does form authentication always created persistent cookie, how can i change it so that when i close the browser , the coookie also goes off ?) Alternatly, if i can create a new form authentication cookie at the same place with the name Cookie2. i am using following code.But cannot see my cookie2 in the folder protected void LinkButton2_Click(object sender, EventArgs e) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "username", DateTime.Now, DateTime.Now.AddMinutes(30), true, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie authCookie = new HttpCookie("cookie2", encryptedTicket); authCookie.Expires = System.DateTime.Now.AddMinutes(30); authCookie.Secure = true; Response.Cookies.Add(authCookie); } Any code support will be of great help. Thx
-
Hi, i am using Form Authentication in my asp.net appication. It creates a persistent cookie named Cookie1 in cookies folder at my system. I want to change/set the Name of this cookie to Cookie2 on the click of a button from page.How can i do that ? (Q: Does form authentication always created persistent cookie, how can i change it so that when i close the browser , the coookie also goes off ?) Alternatly, if i can create a new form authentication cookie at the same place with the name Cookie2. i am using following code.But cannot see my cookie2 in the folder protected void LinkButton2_Click(object sender, EventArgs e) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "username", DateTime.Now, DateTime.Now.AddMinutes(30), true, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie authCookie = new HttpCookie("cookie2", encryptedTicket); authCookie.Expires = System.DateTime.Now.AddMinutes(30); authCookie.Secure = true; Response.Cookies.Add(authCookie); } Any code support will be of great help. Thx