B
Benny Ng
The method of following can generated the cookie for login:
//isPersistent is true;
FormsAuthentication.SetAuthCookie(Session["UserName"].ToString() ,isPersistent) ;
But the second way that of following can't be generated the cookie:
string userRoles = "Administrator";
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket (
1,
Session["UserName"].ToString() ,
DateTime.Now,
DateTime.Now.AddMinutes(30),
isPersistent,
userRoles,
"/") ; //Create authentication ticket
string HashTicket = FormsAuthentication.Encrypt (Ticket) ; //Encrypt the Ticket string
HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket) ;
//Generate Cookie
Context.Response.Cookies.Add (UserCookie) ; //Export Cookie
------------------------------------
And is that two ways of the above can be same to generate the cookie for my login?(if the second one is right to generated cookie)
Any suggestion are appreciated. Thanks!
Benny Ng
//isPersistent is true;
FormsAuthentication.SetAuthCookie(Session["UserName"].ToString() ,isPersistent) ;
But the second way that of following can't be generated the cookie:
string userRoles = "Administrator";
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket (
1,
Session["UserName"].ToString() ,
DateTime.Now,
DateTime.Now.AddMinutes(30),
isPersistent,
userRoles,
"/") ; //Create authentication ticket
string HashTicket = FormsAuthentication.Encrypt (Ticket) ; //Encrypt the Ticket string
HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket) ;
//Generate Cookie
Context.Response.Cookies.Add (UserCookie) ; //Export Cookie
------------------------------------
And is that two ways of the above can be same to generate the cookie for my login?(if the second one is right to generated cookie)
Any suggestion are appreciated. Thanks!
Benny Ng