We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27617
    • 11 Posts
    I am having a problem that is driving me nuts! I finally have WLPE configured and working - I absolutely love the snippet! I have now moved on to developing the logic controlling what content is available to which groups of users. To that end, I am working on some snippets of my own, which utilize the getLoginUserID API function to determine what chunks are presented. My problem is that this function doesn’t return the ID of the logged in user. Sometimes it returns 0, despite the fact that WLPE displays a "Login Success" message and logout form. At other times, the getLoginUserID function returns the ID of a previously logged in user, even though I’ve logged in as a different user.

    However, if I clear the cache from within manager, or make any changes to my snippet (thus forcing a regeneration of the cached page), the next login attempt will work as expected. One time, that is. Subsequent login attempts revert back to the misbehavior. I put some debug statements in my snippet code to echo out the results of calling getLoginUserID and getLoginUserName, as well as the session variables $_SESSION[’mgrInternalKey’] and $_SESSION[’webInternalKey’]. They all display incorrect values, but the WLPE login success form displays the correct user name. Isn’t WLPE utilizing this same function in its logic? Why do I get different results from two calls to the same function from within the same snippet???? It’s as though MODx is pulling from multiple sources for session data, and that makes no sense.

    I have also tried explicitly starting the session by calling startCMSSession(); at the top of my snippet. This didn’t change anything.

    UPDATE: After further testing, I tried specifying a completely different page for WLPE to redirect to after login. This page does nothing except use a snippet to retrieve and display the logged in user name and ID, via getLoginUserID and getLoginUserName. Again, I experience the same behavior: the first time I login, it works as expected - the correct username and ID are displayed. However, subsequent logins using different credentials display the username and ID of the previously logged in user.
      • 22303 MODX Staff
      • 10,725 Posts
      General rule of thumb, don’t allow dynamic content that will be presented differently to various users to be cached.
        • 27617
        • 11 Posts
        OH SH******T! #$%^&* $%^&*( !!!!!

        I can’t believe I just blew three days trying to figure out that I need to uncheck the cache box!!!!!