MyBB Community Forums

Full Version: Problem getting MyBB Integrator logout() to work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've searched the forum but have been unable to get it to work for me. Just so you know, I'm using curl to manage account creation and logging in and stuff remotely, and this page is basically designed to allow one to remotely call MyBB Integrator functions via POST. But that's not where the trouble is; even when I load this page directly with test values for the variables, it still doesn't log me out. Here's the relevant code:

// Initialize MyBB Integrator extension
// Main globals file
require_once("${_SERVER['DOCUMENT_ROOT']}/filepath/globals.inc.php");

global $mybb, $db, $cache, $plugins, $lang, $config;
define('IN_MYBB', NULL);
// MyBB Integrator globals file
require_once "$ForumFolder/global.php";
require_once "$ForumFolder/class.MyBBIntegrator.php";
global $MyBBI;
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config);

This next part probably isn't relevant but here it is anyways:

// Calls requested function from post
$FunctionName = $_POST['FunctionName'];
$Params = array();
foreach($_POST as $Key=>$Value)
{
	if(substr($Key, 0, 5) == 'Param')
	{
		$Params[] = unserialize($Value); // Serialized in case param is actually an array itself
	}
}

This is where I think the problem is:

// Debug
// Forcing values for testing
$_GET['sid'] = $MyBBI->mybb->session->sid;
$_GET['logoutkey'] = $MyBBI->mybb->user['logoutkey'];
$FunctionName = 'logout';

$Success = call_user_func_array(array($MyBBI, $FunctionName), $Params);
// I've taken to setting cookies to display error messages
// Because I'm still learning curl and this way just works the way it's set up...
setcookie("Success", $Success, $DefaultCookieExpire, '/', $Domain);

Any input would be great!
Also, I can post/upload the curl helper functions and everything if anybody needs/wants to see them...
Try to use a full domain

setcookie("Success", $Success, $DefaultCookieExpire, 'http://www.yoursite.com/forum/', $Domain);

Make sure your forum cookie is set you http://www.yoursite.com/forum/ too

And, clear your cokies on your browser before testing.
(2013-06-10, 06:10 AM)un4saken Wrote: [ -> ]Try to use a full domain

setcookie("Success", $Success, $DefaultCookieExpire, 'http://www.yoursite.com/forum/', $Domain);

Make sure your forum cookie is set you http://www.yoursite.com/forum/ too

And, clear your cokies on your browser before testing.

That cookie is just an arbitrary one there for testing purposes, it's not actually for the forum. I have it set up to set the cookies however the integrater wants them, with the only exception being the expire time, and it sets them at the correct domain and the path to the forum folder. I figured out the hard way to not modify the path...

It's not the cookies, I know that because the logout function isn't even attempting to change the cookies, it's like the logout function isn't even trying to set the sid or mybbuser cookies. I'm half tempted to just update the database and remove the user loginkey from the users table, but I doubt that would be a very good idea. Another weird thing is that even if I login using mybb (which currently is completely unmodified) on two different browsers, when I log out on one browser, it stays logged in on the other browser, and that's completely mybb doing its thing, not my code.