Skip to main content
added 47 characters in body
Source Link

I'm migrating my website to a new server and I'm facing a problem since then. Files are identical, so I have no clue.

I want to access the global user variable in a subfolder, which is a custom php site. Here is how I try to access it:

<?php
// require global settings
require_once 'globals.php';
require_once BACKEND_CORE_PATH . '/spoon/spoon.php';

// The domain to be used for session cookies
$cookie_domain = DOMAIN_COOKIE;
$base_url = DRUPAL_URL;

// require the bootstrap include
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get the Drupal user
global $user;

All includes are working fine, but when i dump the $user variable I get the following (while I'm logged in). At least I guess all includes are working since I got no errors.

object(stdClass)#14 (6) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(13) "XX.XXX.XXX.XX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
  ["session"]=>
  string(0) ""
  ["timestamp"]=>
  string(10) "1535128081"
}

Note: The XXX in the hostname is edited by me. Someone has a clue why it isn't working? Can

If I ever have this result ifdump $GLOBALS, i see all drupal isn't loaded correctly?info, but only users says i'm not logged in..

PS: This is Drupal 7

I'm migrating my website to a new server and I'm facing a problem since then. Files are identical, so I have no clue.

I want to access the global user variable in a subfolder, which is a custom php site. Here is how I try to access it:

<?php
// require global settings
require_once 'globals.php';
require_once BACKEND_CORE_PATH . '/spoon/spoon.php';

// The domain to be used for session cookies
$cookie_domain = DOMAIN_COOKIE;
$base_url = DRUPAL_URL;

// require the bootstrap include
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get the Drupal user
global $user;

All includes are working fine, but when i dump the $user variable I get the following (while I'm logged in). At least I guess all includes are working since I got no errors.

object(stdClass)#14 (6) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(13) "XX.XXX.XXX.XX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
  ["session"]=>
  string(0) ""
  ["timestamp"]=>
  string(10) "1535128081"
}

Note: The XXX in the hostname is edited by me. Someone has a clue why it isn't working? Can I ever have this result if drupal isn't loaded correctly?

I'm migrating my website to a new server and I'm facing a problem since then. Files are identical, so I have no clue.

I want to access the global user variable in a subfolder, which is a custom php site. Here is how I try to access it:

<?php
// require global settings
require_once 'globals.php';
require_once BACKEND_CORE_PATH . '/spoon/spoon.php';

// The domain to be used for session cookies
$cookie_domain = DOMAIN_COOKIE;
$base_url = DRUPAL_URL;

// require the bootstrap include
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get the Drupal user
global $user;

All includes are working fine, but when i dump the $user variable I get the following (while I'm logged in). At least I guess all includes are working since I got no errors.

object(stdClass)#14 (6) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(13) "XX.XXX.XXX.XX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
  ["session"]=>
  string(0) ""
  ["timestamp"]=>
  string(10) "1535128081"
}

Note: The XXX in the hostname is edited by me. Someone has a clue why it isn't working?

If I dump $GLOBALS, i see all drupal info, but only users says i'm not logged in..

PS: This is Drupal 7

Source Link

global $user uid = 0 while logged in

I'm migrating my website to a new server and I'm facing a problem since then. Files are identical, so I have no clue.

I want to access the global user variable in a subfolder, which is a custom php site. Here is how I try to access it:

<?php
// require global settings
require_once 'globals.php';
require_once BACKEND_CORE_PATH . '/spoon/spoon.php';

// The domain to be used for session cookies
$cookie_domain = DOMAIN_COOKIE;
$base_url = DRUPAL_URL;

// require the bootstrap include
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

// Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get the Drupal user
global $user;

All includes are working fine, but when i dump the $user variable I get the following (while I'm logged in). At least I guess all includes are working since I got no errors.

object(stdClass)#14 (6) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(13) "XX.XXX.XXX.XX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
  ["session"]=>
  string(0) ""
  ["timestamp"]=>
  string(10) "1535128081"
}

Note: The XXX in the hostname is edited by me. Someone has a clue why it isn't working? Can I ever have this result if drupal isn't loaded correctly?