We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36635
    • 41 Posts
    Hi, I want to have a snippet process a login form that automatically logs the user into another package (phpbb and oscommerce) so I need to muck with session vars and perhaps redirect using headers() to another page.

    What’s the best way to setup the snippet so that I can process and still do header manipulation and/or start a session?

    My only thought is to put the snippet at the top of the template (before any output) to do the processing, and another snippet with the login form itself. Any better way?

    thanks much
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: avibodha at Feb 01, 2007, 01:00 PM

      Hi, I want to have a snippet process a login form that automatically logs the user into another package (phpbb and oscommerce) so I need to muck with session vars and perhaps redirect using headers() to another page.

      What’s the best way to setup the snippet so that I can process and still do header manipulation and/or start a session?

      My only thought is to put the snippet at the top of the template (before any output) to do the processing, and another snippet with the login form itself. Any better way?

      thanks much
      MODx handles it’s own sessions, so you cannot start another session within a MODx request. You’ll need to look into using the events related to WebUser login to perform the auto-login to these other packages without manipulating the session. The SMF Bridge module may provide some inspiration on how to accomplish this, but it will depend heavily on how the target package handles authentication itself...
        • 36635
        • 41 Posts

        MODx handles it’s own sessions, so you cannot start another session within a MODx request. You’ll need to look into using the events related to WebUser login to perform the auto-login to these other packages without manipulating the session....

        Thanks OpenGeek, I will look into the SMF Bridge, but I won’t be using MODx web users for now. I want to take a login and authenticate for the other package (verify user and set session vars myself, it’s fine if the session is already started).

        So...what’s the best way to output to headers using snippets? Just looking to see if I’ve missed anything...

        thanks
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: avibodha at Feb 01, 2007, 01:31 PM


          MODx handles it’s own sessions, so you cannot start another session within a MODx request. You’ll need to look into using the events related to WebUser login to perform the auto-login to these other packages without manipulating the session....

          Thanks OpenGeek, I will look into the SMF Bridge, but I won’t be using MODx web users for now. I want to take a login and authenticate for the other package (verify user and set session vars myself, it’s fine if the session is already started).

          So...what’s the best way to output to headers using snippets? Just looking to see if I’ve missed anything...

          thanks

          If all you want is a redirect, you don’t need to manipulate the headers yourself, just call $modx->sendRedirect()
            • 36635
            • 41 Posts
            If all you want is a redirect, you don’t need to manipulate the headers yourself, just call $modx->sendRedirect()

            Thanks, that sounds good.

            My real question is, what is the best way to set this up? With a snippet first thing in the template (to make sure no output has been sent) and then another with the form? Or is there another place/way to put a snippet or php before any output has been sent?

            Or, is all the output buffered anyway?, so I can call sendRedirect() at any point in the template? That’s easier if so, since I can put all the logic in one snippet in the body of my template. Any idea?

            thanks for your help
              • 36635
              • 41 Posts
              I think I found my answer, it seems that yes, you can call $modx->sendRedirect() at any point in your document because the output has not been sent yet.
              ---thanks
                • 22303 MODX Staff
                • 10,725 Posts
                Correct, all output within the request processing of MODx is done to an output buffer...