We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38205
    • 11 Posts
    I'm trying to set up a login system using php sessions.. this is my first time using modx and its being weird, it seems to carry sessions over to other computers..

    If i login it takes me to a member page that displays a welcome message with this code:
    <?php echo "Welcome back " . $_SESSION['username']; ?>


    But if i go to another computer and go to the member page its displays the same message with the same username as the one i logged in on a completely separate computer with a different IP.

    Is there something different about MODx and sessions i should know?

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      For one thing, you can't have PHP code inline like that. All PHP code in MODx has to be in a snippet.

      For another, if the member page is cached, then it will be cached with all of its content, in this case the login welcome message. You're not really logged in from another computer, it's just that you're getting the cached page from when you were.
        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
        • 33968
        • 863 Posts
        Might be a good idea to have a quick look through the docs if it's your first time using MODX - will save you more than a few hours I'm sure smiley

        Basic Development - http://rtfm.modx.com/display/revolution20/Basic+Development
        Snippets - http://rtfm.modx.com/display/revolution20/Snippets
        Caching - http://rtfm.modx.com/display/revolution20/Caching
          • 38205
          • 11 Posts
          Quote from: sottwell at Jan 06, 2012, 12:44 AM
          For one thing, you can't have PHP code inline like that. All PHP code in MODx has to be in a snippet.

          For another, if the member page is cached, then it will be cached with all of its content, in this case the login welcome message. You're not really logged in from another computer, it's just that you're getting the cached page from when you were.

          ya that php code was in a snippet. is there a way to make the snippet / page not cached?

          edit: I found the page cache check mark.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            To have only the snippet's output not cached, for Evo use [!...!] and for Revo use [ [!...] ] in fact for Revo all elements can be uncached by adding the ! to the beginning tags.
              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