MyBB Community Forums

Full Version: Checking MyBB User is Logged In
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
What is the best way to check if a MyBB User is currently logged in? I am currently using
if($_COOKIE['mybbuser'])
But I don't think that is always reliable. Is there any other ways I can check?
if($mybb->user['uid'])
Thanks, I'll give that a go Smile
that doesn't work, it says no-one is logged in when i am.

Would
if($mybb->user)
work?
Dempsey Wrote:that doesn't work, it says no-one is logged in when i am.

Would
if($mybb->user)
work?
In
if($mybb->user['uid'])


Did you change uid to the user id number of the user you are trying to see if online?

kodaks Wrote:Did you change uid to the user id number of the user you are trying to see if online?
I'm not trying to see if a paticular user is logged in, just if anyone is logged in.
Dempsey Wrote:
kodaks Wrote:Did you change uid to the user id number of the user you are trying to see if online?
I'm not trying to see if a paticular user is logged in, just if anyone is logged in.

Then I *think* that the "if($mybb->user['uid'])" will not work for you, as it is for a specific user. I am not totally sure about that though, as I am not experienced with php.
What exactly are you trying to do? Find out if the current user is logged in, or looking at if someone ELSE is logged in?
As long as you're using the "MyBB core", ie require "./global.php"; then everything will be setup and you should be able to use $mybb->user['uid']
$mybb->user['uid'] returns the UID of the current user. You don't change 'uid' to the user id of the person you want to look at (eg. $mybb->user[56] for user 56 is WRONG)
Pages: 1 2 3