We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7045
    • 225 Posts
    Am I the only one having this issue? I have cleared the cache, tried multiple browsers, made sure I was logged out of the manager, pretty much anything I could think of that might affect the situation.

    I can't get the login to redirect to the prior page. Maybe a bug??
      • 7045
      • 225 Posts
      Nobody else has this issue?
        • 3749
        • 24,544 Posts
        Some user agents don't set the $_SERVER['http_referer'] variable, which is used in the redirection. You could create a simple snippet to test that:

        <?php
        return 'Prior Page URL: ' . $_SERVER['http_referer'];
        


        FYI, the home page is the default "page not found" page, so any invalid URL will take you there.
          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
          • 7045
          • 225 Posts
          Thanks, Bob. I will give it a try. I can redirect the use to whatever page I want, no problem. I just can't redirect them to their prior page using "&redirectToPrior".

          Come to think of it, I was able do this a few versions back. But after a couple updates, I can't seem to get it to work.
            • 37286
            • 160 Posts
            I'm having the same problem with redirectToPrior not working. When looking at the login form using firebug, I can see that the hidden input field "returnUrl" contains the referring page url. However, after I log in all I see is the login page with the link to log out.
              • 37131
              • 111 Posts
              HTTP_REFERER is shown on php.net documentation as deprecated and Bob's code on my system shows:
              "Notice: Undefined index: http_referer in D:\xampp\htdocs\modxzh\core\cache\includes\elements\modsnippet\43.include.cache.php on line 7
              Prior Page URL: "

              Anyway,
              redirectToPrior seems to work if &loginResourceId is not set in Login snippet,
              but it doesn't work with logout - I don't know if it is supposed to be this way or if it's a bug.
              IMO it should work the same way as with login.
                ---
                Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
                • 3749
                • 24,544 Posts
                Note that the referer won't be set if you type in a URL. You have to go there via a link.


                ------------------------------------------------------------------------------------------
                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
                  • 37131
                  • 111 Posts
                  I've tested this code by including it in my site's template.
                    ---
                    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
                  • I should think that it would work on login, but not logout. If you try to access a protected page when you're not logged in, you'll end up on the "unauthorized" page, which probably has a login form. So when you log in, you want to be forwarded/redirected (whatever) to the page you tried to access.

                    Upon logging out, you need to be sent to some non-protected page. If you were browsing protected pages, getting sent to the previous page would just throw you back to the "unauthorized" page.

                    It also seems logical to me that a specific property for a login page should override any "previous page" propery; one of the two has to be given precedence.
                      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
                      • 37131
                      • 111 Posts
                      It depends on how site is structured, I just think that it should be left to site developer to decide how Logout works. It would need just similar option for Logout as is for Login. But it's nothing critical smiley
                        ---
                        Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding