We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42445
    • 9 Posts
    Quote from: sottwell at Jan 04, 2013, 01:47 AM
    The SESSION is valid on all pages within the same domain; are you going from domain.com to www.domain.com or vice verse? Where, exactly, is your FormIt form posting to? And what does that post action do?
    no, i am not switching any subdomain. all pages are handled by modx.

    the post action just sets the session-variable and FormIt calls the same page the form was submitted from. nothing special about that. i have no clue why the session-variable is limited to this very page. maybe the session-id is saved to a cookie which is valid for that page...
      • 4172
      • 5,888 Posts
      what is your formit-hook-snippet-code now?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42445
        • 9 Posts
        the FormIt-hook-snippet is a one liner:
        <?php
        $_SESSION['testCustomerId'] = 15;
        return true;


        the snippet for the login (placed in the template):
        <?php
        if($_SESSION['testCustomerId'] == 15) {
            return "You are loged in";
        } else {
            return '<form...';
        }
        
          • 4172
          • 5,888 Posts
          This should work.

          Is formit placed before your snippet in the template?
          Are you calling your snippet uncached?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42445
            • 9 Posts
            The snippets are called uncached; the FormIt snippet call is right before the form-tag:
            [[!FormIt?
            &hooks=`LoginSubmit`
            ]]
            <form...


            LoginSubmit is the one-liner from above that just sets the session-variable
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Indeed, works for me.
              [[!checkSession]] [[!FormIt? &hooks=`fiLogin`]]
              <form action="[[~[[*id]]]]" method="post"><input name="fiSubmit" type="submit" value="Submit" /> </form>
              


              And on other pages just have the checkSession snippet.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 42445
                • 9 Posts
                something is resetting my session on every call; still searching...
                but good to know that it should work!
                thanks susan and bruno!