Is there a quick way to programatically check if a web user is logged in? I cant seem to find a straightforward function/api call that will return a boolean value for if a user is logged in or not. Any tips would be appreaciated. thanks.
-
☆ A M B ☆
- 24,524 Posts
If you’re really interested, I’ve got an article dealing with the SESSION array MODx sets when a user is logged in; if you log in as the sample user (test - testing) you’ll get a view of the entire SESSION.
http://www.sottwell.com/article-sessions.html
-
MODX Staff
- 10,725 Posts
Please note that directly using SESSION variables to check for logged in users is bad and will be deprecated in the future. It is always better to use the API functions to check if a user is logged in; this way if the session variables change in the future, you code will still work.
-
☆ A M B ☆
- 24,524 Posts
It’s just a simple print_r() that I use all the time for debugging:
echo "<pre>";
print_r($_SESSION) // put whatever you want to view, object or array, here
echo "</pre>";