MyBB Community Forums

Full Version: SDK and Login Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Why is class_SDK.php no longer distributed with MyBB? Is it not being supported/updated anymore?

Also wondering if anyone has any ideas how I can check if a user is logged in using the SDK. I currently check for the cookie:

if($_COOKIE['mybbuser'])
					{
                        unset($user);
                        global $userUID;
						$logon = explode("_", $_COOKIE['mybbuser'], 2);
						$userUID = $logon[0];
						//echo "<br><br><b>User:  ".$userUID."<br><br>";
						$user = $mybbSDK->getProfile($userUID);
					}
but it seems that it isnt always reliable.

I've tried add a function to the SDK:
function checkLogin()
{
 if($this->$mybb->user['uid'] != 0) 
{
    return "Welcome back!";
    }
else 
{
  return "Hello there visitor!";
}
But that didnt work. It always reutned guess. Anyone have any other ideas how I can do it?
I cant just include Global to do the login, as I also use the MyBB datacache throughout my site, that is why I have to use the SDK, well I think I do, unless anyone has any ideas how I could do it different?
To check for login you can just use what you've already written
global $mybb;
if(empty($mybb->user['uid'])){
// guest
}
else{
//logged in
}
Thanks, but still no luck Sad

I changed my checkLogin function to:
function checkLogin()
{
	global $mybb;
	return $mybb;
}
but it returns:
[user] => Array
        (
        )
But using the cookie code on the same page it says that I'm logged in.
Try this:
global $mybb;
if($mybb->user['uid'] != "0"){
// Member
}
else
{
// Guest
}
cheers Michael83 buts thats what I had in my CheckLogin function originally
Not exactly, I removed the $this->.
ah yea.

But wether I have the $this-> in the sdk function or not, the $mybb array returned is near empty:
mybb Object
(
    [cwd] => .
    [input] => Array
        (
            [id] => home
        )

    [user] => Array
        (
        )

    [usergroup] => Array
        (
        )

    [settings] => Array
        (
        )

    [magicquotes] => 1
    [config] => Array
        (
        )

    [debug] => 
    [request_method] => get
    [clean_variables] => Array
        (
            [int] => Array
                (
                    [0] => tid
                    [1] => pid
                    [2] => uid
                    [3] => eid
                    [4] => pmid
                    [5] => sid
                )

        )
Can you please specify what you want to do or what you need?
At MPSounds.net I use MyBB as the forum and the site login throughout the site. I use the SDK so that I can access the MyBB Datacache anywhere within my site.

I currently check if a user is logged in by looking for the existance of the cookie, but that doesn't seem 100% reliable as since I have started using that I have been having some problems.

I am trying to find an alternate way to find out if a user is logged in, but not from within the forum, but outside of it, using the SDK, or another way if it works.

I think I have probably just made it sound even more confusing Toungue
Pages: 1 2