locked
Login with "Remember Me" does not redirect after creating persistent cookie RRS feed

  • Question

  • User1092566934 posted

    Hello, 

    When the user logs in and checks "Remember Me" option I create a persistent cookie and depending on the role of the user I redirect to a page or another. The problem is that when the persistent cookie is created does not redirect to the corresponding page, it stays in login form.

    What am I missing? This is my authentication code:

    if (cbRememberMe.Checked)
    {
        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(tbUser.Text, true, 24 * 60 * 30);
        string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
        HttpCookie cookie = new HttpCookie("SV_User", encryptedTicket);
        cookie.Expires = DateTime.Now.AddDays(30);
        HttpContext.Current.Response.Cookies.Set(cookie);
    }
    else
        FormsAuthentication.SetAuthCookie(user, false);
    
    if (Roles.IsUserInRole(user, "Admin"))
        Response.Redirect("~/Admin/Index.aspx");

    Tuesday, April 29, 2014 11:41 AM

Answers

All replies