10 Replies Latest reply on Oct 20, 2007 7:47 PM by (juster3)

    Auto login after new user registration

      Hello,
      I would like to go directly to a restricted page (add session variables for username, level, etc) after a new user is registered, without first going to the login page. Is there a way to do this? I tried adding a login user behavior to my new user registration page, but it disabled the form validation on the page. I also tried copying some of the login page code (login transactions) into the new user registration page, but that didn't work either... any help would be greatly appreciated!

      Steve
      BTW, I am not utilizing email activation
        • 1. Re: Auto login after new user registration
          Tutorial here:
          http://www.interaktonline.com/Documentation/MXKollection/
          Click How To link on the left, then click the How to automatically login
          after registration link.

          MXK3 isn't exactly ADDT, but the tutorial is still applicable.

          --
          Alec
          Adobe Community Expert
          • 2. Re: Auto login after new user registration
            Level 1
            Ok, I figured it out:
            I changed the redirect page to the page I wanted to go to after registration. I used the blue lightening arrow to pass the id of the last insert. I then created a recordset on the second page and set the sessions there...
            Hope that saves someone some time if they want to auto login!

            Steve
            • 3. Re: Auto login after new user registration
              Level 1
              Ok, I am still having some issues with this automatic login. I followed the advice of the tutorial and set the session variables kt_login_id, kt_login_user, and kt_login_level in a custom trigger.
              I have also added a "restrict access based on level" to the following pages. The strange thing is that sometimes everything works fine after the new user registration, but sometimes I get redirected to the login page with an error message. When I login through the login page, it works fine. This is driving me crazy. Any suggestions?

              Thanks!
              • 4. Re: Auto login after new user registration
                Level 1
                Figured it out...
                I was resetting the session variables on each page with some extra code that I didn't need. After I deleted that, it seems to work great. ADDT is great once you figure out all the little quirks!
                • 5. Re: Auto login after new user registration
                  Level 1
                  Hey Steve, One thing I still do not understand very well is how to create a "Session Variable" using DW, ADDT & CF pages?

                  I notice that ADDT creates session variables automatically when I create various forms but do you know what steps one takes to create a "Session Variable" of my own using the ADDT tools or transactions?

                  I need to have a "variable" that persists across pages so I can use it later on my page 6 & 7.

                  Thanks,
                  jlig
                  • 6. Re: Auto login after new user registration
                    Level 1
                    I spoke too soon. Unfortunately, the restricted pages are now redirecting me again! I have been working on this all afternoon. Any advice would be really appreciated!

                    I am trying to auto login users from the new user registration page. So I added a custom trigger to that page as follows:

                    //start Trigger_Custom trigger
                    function Trigger_Custom(&$tNG) {
                    // Set session variables
                    $_SESSION['kt_login_id'] = $tNG->getPrimaryKeyValue();
                    $_SESSION['kt_login_user'] = $tNG->getColumnValue('email1');
                    $_SESSION['kt_login_level'] = $tNG->getColumnValue('level');

                    Then information gets inserted into the database and the session variables are created just fine. I have checked this on the following pages. However, when I use the "restrict page" based on the level, it redirects the page to the login.php page. If I login through the login.php page, then the restricted pages show just fine.

                    Am I missing something here? What is the login page doing that my custom trigger is not? I am also confused by how the "save my information" works. Where is it storing that info? Even when I clear my cookies and sessions, and saved forms, the login information is still stored???

                    Thanks!!!!
                    • 7. Re: Auto login after new user registration
                      Level 1
                      Still struggling with this-- I've been writing my own code to restrict access to pages, but would really prefer to use the ADDT functions instead. I would think it would be pretty common for developers to want to autologin after a new user registration...
                      Thanks so much for any advice!!
                      • 8. Re: Auto login after new user registration
                        Did you ever figure this out?
                        I have the exact same problem. It works about 50% of the time.
                        I make sure and logout and confirm that the session variables are cleared, and then create a new account.
                        The first time I create a new account, it sends me back to the login page and says I am restricted. I create another account and sure enough it sends me right along with the correct end result.

                        I traced it down to the registration form not always running the custom trigger and setting the session variables, but I can't figure out what makes it fail sometimes.
                        • 9. Re: Auto login after new user registration
                          Level 1
                          Unfortunately, no. That's interesting that you traced it back to the custom trigger only sometimes running. It seems like my session variables are getting set just fine, but there is something about using the "restrict access to page" that doesn't work-- like it's checking for something other than id and level. So as of now, I am just restricting access to pages manually by checking the session variable and redirecting... if you figure it out, please let me know!
                          Cheers,
                          Steve
                          • 10. Re: Auto login after new user registration
                            Level 1
                            Well I finally figured out a work around... I am sure others will run into this problem and if someone can explain it to me I would be happy. But for now this will work.

                            The above code that Steve U posted works for me exactly 50% of the time. It will work every other time, why I don't know. I even changed all of my temp and session directories in php configuration, changed from php5 to php4 and still no fix.

                            Here is what I did to get it to work:
                            On your registration form underneath the insert transaction you copy and paste the login transaction (that you generate on a login page).
                            *Change tNG_login(this is your server connection)
                            *Change the POST value to match your submit button on your registration form, mine is KT_Insert1.
                            *Modify the redirect trigger to go to the page you want to redirect to after registration.
                            *Change the kt_login_user and kt_login_password addColumn values to match the username and password fields in your registration form, mine are email_usr and password_usr
                            *comment out the kt_login_rememberme addColumn (or if you need this, modify the code to allow for it in the registration form)

                            I have now successfully registered a new account and had it auto-login to the user protected area 10 times in a row now, so this should be working.

                            If you want some sample code here it is:
                            // Make a login transaction instance
                            $loginTransaction = new tNG_login($conn_connection);
                            $tNGs->addTransaction($loginTransaction);
                            // Register triggers
                            $loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
                            //$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
                            $loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "user/confirmlogin.php");
                            // Add columns
                            $loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "email_usr");
                            $loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "password_usr");
                            //$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");
                            // End of login transaction instance