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 ?
-
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.
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 ?
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 ?
-
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...