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

    I’m not particularly sure whether this is a modx problem or a PHP fundamental problem, but the issue is, I have a snippet which sets a session variable on page A so that page B can receive the variable and display it. page A clears the session each time it loads the page, so that if a new choice on page A is chosen, then page B isn’t stuck with the wrong variable. I hope that makes sense.

    Now, this works beautiful as it should, but if the user presses on their back browser button to go back to page A, the session isn’t cleared via the snippet, so page B still has the old page A variable values. If I goto page A via a link instead of simply going back from page B, it works fine. Both resources/pages are set to not cache in the modx settings, so I’m not sure what’s up.

    Does anyone have any ideas? Should I include the PHP session code I’m using?

    Thanks!
      • 3749
      • 24,544 Posts
      I think the problem is that the client’s browser is returning to a cached version of the page so the snippet isn’t executing (because it doesn’t exist in the final HTML of the page).

      You might try putting this at the top of the page in the <head> section(not sure if it will work reliably):

      <meta http-equiv="expires" value="Thu, 16 Mar 2000 
      11:00:00 GMT" />
      <meta http-equiv="pragma" content="no-cache" />

        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
        • 13388
        • 33 Posts
        Ah, sounds like it’d work, but no dice. I thought that’s what the cache functionality would do, anyway.

        You can see what happens, here: http://www.falkadventures.com/Reservations.html

        Click on a reservation and it’ll work beautifully the first time, but if you go back and decide to make a different reservation then it’s kaput. I’m not sure what to do sad
          • 13388
          • 33 Posts
          Anyone have any ideas? I’m running out of options sad
            • 3749
            • 24,544 Posts
            I’m assuming that there’s a snippet on page 8 that decides what to display and that page 8 is designated as uncached in MODx. Try making the snippet cached: [[snippet]].

            If that doesn’t work, try caching page 8 but making the snippet cached: [!snippet!].

            If neither of those works, post the snippet here.
              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