Consider the following script.
define('DRUPAL_ROOT', getcwd() . "/..");
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$username = "Silox";
$password = "hidden";
global $user;
$account = user_authenticate($username, $password);
// Woah, it seems like we don't know this user, let's create him!
if (!$account) {
$userinfo = array(
'name' => $username,
'pass' => $password,
'init' => $username,
'status' => 1,
'access' => REQUEST_TIME,
);
$account = user_save(drupal_anonymous_user(), $userinfo);
$account = user_authenticate($username, $password);
}
$user = user_load($account, TRUE);
drupal_session_regenerate();
?>
This script logs me in or creates a new account when the username and password combination doesn't exist. When I put this script in the base directory of my Drupal installation, everything works perfectly fine.
However, when I put it in the root directory of the PhpBB subdirectory and change the DRUPAL_ROOT
to getcwd() . "/.."
to compensate for the extra folder, it doesn't work. If I print out my user array at the end of the function, I get a nice array with corresponding correct info but however, if I return to my Drupal site, I am not logged in.
How can this problem get solved?