I have a sqldatasource and a gridview.
I’m using forms authentication.
After the user logged in , I’m crypting his name
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.text, DateTime.Now,
DateTime.Now.AddMinutes(30), true, false);
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
ck.Expires=tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
In the redirected page I need to set in the sqldatasource , where -> parameter source : cookie
-
BUT,
-
1.I don’t know the cookie name because as I can see it doesn’t have one.
-
2.Since the cookie was crypted , the sqldatasource must use the decrypted cookie..well..I’m not sure what to do in order to use the username string.
All in all , I’m trying to crypt his name and in the redirected page to use the logged user name in a sqldatasource where condition . I can do this if I Don’t crypt the cookie but..since the cookie can be edited..I don’t want ppl to edit cookies.
Ans 1. The default name of the FormsAuthentication.FormsCookieName is “.ASPXAUTH”.
But if you wish over write the name then you will have to do it in the config