I am using following code to create a authentication cookie, but the problem is user is not getting authenticated. Please let me know if I am missing somthing.

HttpCookie authCookie = FormsAuthentication.GetAuthCookie(UserLogin.UserName, true);
               FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
               FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userDataString);
               authCookie.Value = FormsAuthentication.Encrypt(newTicket);
               Request.Cookies.Add(authCookie);
               string url =  FormsAuthentication.GetRedirectUrl(UserLogin.UserName, true);
               Response.Redirect(url);

http://www.asp.net/learn/security/tutorial-03-cs.aspx

try this...

one more thing UserLogin.UserName instead of this

manually write your name

#
FormsAuthentication.GetRedirectUrl("Jigsaw", true);
#
Response.Redirect(url);

and after redirection on page load check

if(Request.IsAuthenticated)
if yes then

UserLogin.UserName is nothing..

make a check and let me know the o/p

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.