I have created a encrypted cookie using formsauthenticationticket in aa.mydomain.com and when i am decripting that cookie in bb.mydomain.com website i am getting an exception "Unable to validate data." how to decrypt that cookiee in bb.mydomain.com and i
specified the cokiee domain name in aa.mydomain.com website.
My Code in aa.mydomain.com:
rmsAuthenticationTicket fatPassword = new FormsAuthenticationTicket(1,
pathipati
Member
16 Points
314 Posts
How to decrypt forms authentication cookie across the domain in asp.net 3.5
Dec 18, 2010 07:42 AM|LINK
Hi,
I have created a encrypted cookie using formsauthenticationticket in aa.mydomain.com and when i am decripting that cookie in bb.mydomain.com website i am getting an exception "Unable to validate data." how to decrypt that cookiee in bb.mydomain.com and i specified the cokiee domain name in aa.mydomain.com website.
My Code in aa.mydomain.com:
rmsAuthenticationTicket fatPassword = new FormsAuthenticationTicket(1,
txtUserName.Text, DateTime.Now,
DateTime.Now.AddMinutes(5), false, txtPassword.Text),
FormsAuthentication.FormsCookiePath);
HttpCookie ckPwd= new HttpCookie("ckPwd",
FormsAuthentication.Encrypt(fatPassword));
ckPwd.Domain = ConfigurationSettings.AppSettings["Domain"];
Response.Cookies.Add(ckPwd);
My Code in bb.mydomain.com:
HttpCookie ckPassword= Request.Cookies["ckPwd"];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(ckPwd.Value);
string val = ticket.UserData;
Ebad86
Member
202 Points
37 Posts
Re: How to decrypt forms authentication cookie across the domain in asp.net 3.5
Feb 21, 2012 04:43 AM|LINK
you can code your web application to allow cookies across multiple subdomains. You will need to set the domain equal to:
Response.Cookies("CookieName").Domain = ".mydomain.com" Hope it helps.