Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Louis 37 posts 59 karma points
    Jan 18, 2012 @ 17:40
    Louis
    0

    Create a Forms Authentication Site

     

    hi all,

    My site works great with the backend Umbraco stuff for a user to log in and change the content etc. What i am looking to do is create a login reg section for the front facing site so users can leave comments etc.

    I have created my login reg page and tried using .NET Forms Authentication but nothing seems to work! When I add the cookie, I refresh and it's not there. This method works great in non Umbraco sites, so I am assuming that I need to do something different with Umbraco.

     

    Here is my Forms Authentication code, which doesn't seem to add cookies or SetAuthCookie:

    Users Users = new Users();

                ENT_User User = Users.GetUser(this.txtLogin.Text, this.txtLoginPassword.Text);

                if (User.ID != Guid.Empty)

                {

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,

                      User.Email,

                      DateTime.Now,

                      DateTime.Now.AddDays(12),

                      true,

                      User.ID.ToString(),

                      FormsAuthentication.FormsCookiePath);

     

                    // Encrypt the ticket.

                    string encTicket = FormsAuthentication.Encrypt(ticket);

     

                    // Create the cookie.

                    Response.Cookies.Add(new HttpCookie("WatchMyWalletLoginDetails", encTicket));

    }

     

     

    When I hover my mouse over the cookies in Debug the cookie is there, but when I refresh and come through the process again, the Cookie is not there.

     

    Does anyone have any ideas as to what the problem is?

     

    Thanks

     

     

     

     

     

     

     

     

     

     

     

     

  • Rodion Novoselov 694 posts 859 karma points
    Jan 18, 2012 @ 17:59
    Rodion Novoselov
    0

    Hi. The first and maybe silly question - does your browser accept cookies from this site? Have you tried to inspect the response from the site with Fiddler or any similar tool to verify that the cookie is there? Keep also in mind that user's (but not member's) authetication in Umbraco is someway different from the standard asp.net forms authentication, so that if you whant to implement your own custom login form you'd better look into the sources of the standard login page of Umbraco and follow the same procedure as it does.

Please Sign in or register to post replies

Write your reply to:

Draft