We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29606
    • 63 Posts
    I call the snippets uncached, even made the pages uncached.
    Deleting the cache files don’t change anything.

    As a matter of fact, the only solutions I’ve seen are
    - either when a user is logged out of the web context, a manager logs into the manager context and flushes all sessions before the second user can log in the web context,
    - or you have to close your browser and launching it again before login in.

    Have you tried with the login snippet on the same page as your UserSettingTest snippet, to check the result when logged in as user A, logged out, then logged in again with user B ?
      • 22303 MODX Staff
      • 10,725 Posts
      You can’t do this in a single page with user settings, because they are stored to/restored from session and loaded at the beginning of the request.
        • 29606
        • 63 Posts
        It still doesn’t work for me...
        After flushing all the sessions, then logging with a user-A, UserSettingTest returns user-A ID.
        After logging out, UserSettingTest returns "No SMF_ID is set".
        After logging in with user-B, UserSettingTest returns user-A ID...

        I don’t know what to do, but I think maybe this might not be the best way to have a user-profile related custom field.
        Is there another way ?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: Thalion at Aug 25, 2009, 04:10 PM

          I don’t know what to do, but I think maybe this might not be the best way to have a user-profile related custom field.
          Is there another way ?
          Custom profile data is best kept in a custom table that you relate to the user table. This way you isolate your customizations from the core tables and reduce potential problems/conflicts on upgrade.
            • 29606
            • 63 Posts
            Still looking into this, I think I might have a lead, but I will need help.

            I found out that the Usersettings as defined in modUsersettings are stored in _userConfig.
            In modx.class.php, function getUser shows that _userConfig is refreshed only if $_SESSION["modx.{$contextKey}.user.config"] (which keeps a copy of _userConfig) is not set. However, this session variable is not unset when you log out, thus the next user logging in receive the previous user Usersettings.
            I guess that upon logging out, this session variable should be flushed, am I right ?
              • 22303 MODX Staff
              • 10,725 Posts
              Every distinct user should have a unique session, so, no, I don’t see how that could be the problem, but I’ll look into it...