Bootstrap external login from subfolder isn't working 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' =&gt; $username,
        'pass' =&gt; $password,
        'init' =&gt; $username,
        'status' =&gt; 1,
        'access' =&gt; REQUEST_TIME,
    );
    $account = user_save(drupal_anonymous_user(), $userinfo);
    $account = user_authenticate($username, $password);
}

$user = user_load($account, TRUE);
drupal_session_regenerate();
?&gt;


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?
I think this is related to how you're defining the DRUPAL_ROOT constant.

Several times I've had to make scripts interact with Drupal from sub folders, and I've found the simplest way to make sure things work correctly is to preface my code with the following:

&lt;?php
chdir('../');
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
?&gt;


The key thing here is the chdir() call.

Also, when creating a path and you want to go up one folder, its usually ../ not /.., because directory paths should usually end with a /.