We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36467
    • 73 Posts
    There isnt any other way to access session inside modx snippet ??
      • 3749
      • 24,544 Posts
      I'm not sure what you mean. The only way I know of is $_SESSION.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 36467
        • 73 Posts
        Bob : I tried different ways to make it work. I see external session isnt accessible in modx so i created snippet which will print captcha image but we are using tinyMCE so its adding <p></p> tag around and so its failed, so i installed modx on localhost and used same snippet without tinyMCE but that also didnt worked, i think something is getting printed or modx sets text/html header before i set image/png header (FYI i am using blank template). But the good thing is that i can see/access session variable "varicode" set by captcha snippet, see the image attached.
        I played with spform also, i am able to see maths captcha on my form. we can only create contact page with spform ? can i create enewsletter form with spform ? this my be foolish question, but i am new to modx.
          • 36467
          • 73 Posts
          Somehow i managed to make it work. In case if someone stuck in same problem.
          1) I added captcha image creation code in snippet (same snippets holds code for saving the data to DB)
          2) I saved created captcha image to a image file,
          3) stored verification code to session.
          4) passed saved image file name to chunk so i can display it there.
          5) and when user post form i deleted the image.

          There are two drawbacks of this scenario
          1) There is no "refresh image"
          2) If user doesnt post the form captcha image file will not get deleted.

          This is temporary workaround, i will soon fine some proper way to do it. But for now i will stick to this.

          Thanks Bob for being with me and helping hand.
            • 3749
            • 24,544 Posts
            Yes, SPForm is very limited and only does a simple contact form. The plus side is that, for most people, you have a working contact form as soon as you install it.

            I'm glad you found something that works for you.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              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
              • 36467
              • 73 Posts
              yes you are right SPform is really easy to use, I installed it and i had my demo contact page withing a seconds. [ed. note: amitpatil last edited this post 14 years, 1 month ago.]