We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23359
    • 14 Posts
    Hello,

    I’ve got a problem.

    For a captcha script I am writing I need to start a session. The captcha script generates a picture (png) en starts a session with the code in it.
    Now I can’t figure out how to start this session because after submitting the form print_r($_SESSION) is empty.
    I downloaded modxapi.php to solve the problem, but it doesn’t work yet.

    The only way it will work is if I log in on the manager. But that’s not the solution because I want to use the captcha in a contactform, accessable for anyone who visit the website.

    And.. veriword doesn’t work for me..

    Anyone?

    Thanks, Gr Pieter...!
      • 15083
      • 697 Posts
      There is captcha built into MODx.
      If you use eForm you can turn it on using one of the parameters.
        • 22303 MODX Staff
        • 10,725 Posts
        If you want to use the MODx session, you need to author your script as a MODx Snippet and serve it as a MODx Resource. Otherwise, you’ll have to find a way to include the manager/includes/config.inc.php file and use the startCMSSession() function defined in that file.
          • 23359
          • 14 Posts
          Quote from: OpenGeek at Oct 30, 2009, 08:30 AM

          If you want to use the MODx session, you need to author your script as a MODx Snippet and serve it as a MODx Resource. Otherwise, you’ll have to find a way to include the manager/includes/config.inc.php file and use the startCMSSession() function defined in that file.

          I did that.. tried 2 options:

          1. include modxapi.php with following code:

          include_once($_SERVER['DOCUMENT_ROOT'] . '/modxapi.php');
          $modx = new MODxAPI();
          $modx->connect();
          $modx->startSession();
          $modx->getSettings();


          2. include config.inc.php with following code:
          include_once($_SERVER['DOCUMENT_ROOT'] . '/manager/includes/config.inc.php');
          startCMSSession();


          Both ways don’t work, accept when you login to the manager.
            • 23359
            • 14 Posts
            Quote from: jusmeig at Oct 30, 2009, 08:28 AM

            There is captcha built into MODx.
            If you use eForm you can turn it on using one of the parameters.

            That’s veriword, but I don’t want to use it..
              • 15083
              • 697 Posts
              Quote from: pierro at Oct 30, 2009, 09:08 AM

              That’s veriword, but I don’t want to use it..

              Why not?
                • 23359
                • 14 Posts
                Quote from: jusmeig at Oct 30, 2009, 09:15 AM

                Quote from: pierro at Oct 30, 2009, 09:08 AM

                That’s veriword, but I don’t want to use it..

                Why not?

                Because I did not get it to work, I suspect it uses PHP5 and my php version is lower..
                  • 3749
                  • 24,544 Posts
                  Quote from: pierro at Oct 30, 2009, 10:15 AM

                  Quote from: jusmeig at Oct 30, 2009, 09:15 AM

                  Quote from: pierro at Oct 30, 2009, 09:08 AM

                  That’s veriword, but I don’t want to use it..

                  Why not?

                  Because I did not get it to work, I suspect it uses PHP5 and my php version is lower..

                  The odds are that if veriword.php doesn’t work for you, your custom captcha won’t work either (it works fine in PHP4). I’m going to guess that your problem is that GD and/or Freetype are either not enabled or misconfigured.

                  The captcha in SPForm is slightly different (though the file is still called veriword.php), you might take a look at it -- you’re welcome to use that code if it works for you.

                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 23359
                    • 14 Posts
                    Quote from: BobRay at Oct 30, 2009, 12:19 PM

                    Quote from: pierro at Oct 30, 2009, 10:15 AM

                    Quote from: jusmeig at Oct 30, 2009, 09:15 AM

                    Quote from: pierro at Oct 30, 2009, 09:08 AM

                    That’s veriword, but I don’t want to use it..

                    Why not?

                    Because I did not get it to work, I suspect it uses PHP5 and my php version is lower..

                    The odds are that if veriword.php doesn’t work for you, your custom captcha won’t work either (it works fine in PHP4). I’m going to guess that your problem is that GD and/or Freetype are either not enabled or misconfigured.

                    The captcha in SPForm is slightly different (though the file is still called veriword.php), you might take a look at it -- you’re welcome to use that code if it works for you.



                    I’ve have PHP4.. veriword.php prints the following error:
                    Fatal error: Call to undefined function: imagettfbbox() in /usr/home/abc/domains/abcvathorst.nl/public_html/manager/includes/veriword.php on line 124

                    So I guessed that imagettfbbox() is a PHP5 function?

                    With the script what I coded myself I get a captcha picture, but if I post the form the session[’captcha_code’] is not set.
                    So GD and/or Freetype not seems to be the problem.

                    Somehow MODX destroys all sessions in $_SESSION if you are not logged into the manager. If I’m logged in the manager my script works.., the captchacode is set in a session.

                      • 23359
                      • 14 Posts
                      Still didn’t figure out to solve this problem.
                      Seems like I can’t use sessions in an external php file in ModX.

                      Have anyone more info about modx & sessions?