how to send $user variable from drupal to another php non-drupal page under same root? I have drupal cms and another php site with each own session and db etc on same root.

What I want is to pass somehow the drupal $user variable with all the login details of the user to the other non-drupal php site in order to bypass the login and make the user logged in there too.

The non-drupal site has its own login/register and sessions etc. I want to override this by getting the user info from drupal registration.

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


I tried to use the above code on the index of the non-drupal site, but I get errors about session and headers that already sent.

Any help?
I have a similar setup running; what I did was sending the session ID as a URL parameter, including the "bootstrap.inc" file, bootstrapping the database, and then looking up the info I needed.

Example where I've stored some info in the session:

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);

if (@$_GET["sid"]) {
  $_SESSION["sid"] = @$_GET["sid"];
}

if (@$_SESSION["sid"]) {
  //Get the get username/role from the database
  $result = db_query("SELECT session FROM {sessions}
    WHERE uid &gt; 0 and sid = '%s'", array(
      $_SESSION["sid"],
    )
  );

  while ($row = db_fetch_object($result)) {
    $_SESSION += unserializesession($row-&gt;session);
  }
}

function unserializesession($data) {
  if (strlen( $data) == 0) {
    return array();
  }

  // Match all the session keys and offsets.
  preg_match_all('/(^|;|\})([a-zA-Z0-9_]+)\|/i', $data, $matchesarray, PREG_OFFSET_CAPTURE);

  $returnArray = array();
  $lastOffset = null;
  $currentKey = '';

  foreach ($matchesarray[2] as $value) {
    $offset = $value[1];

    if (!is_null($lastOffset)) {
      $valueText = substr($data, $lastOffset, $offset - $lastOffset);
      $returnArray[$currentKey] = unserialize($valueText);
    }

    $currentKey = $value[0];
    $lastOffset = $offset + strlen($currentKey) + 1;
  }

  $valueText = substr($data, $lastOffset);
  $returnArray[$currentKey] = unserialize($valueText);

  return $returnArray;
}