I am loading the core drupal 7 components through an external file by loading bootstrap. While the core drupal functions work properly, when I try to access variable_get I keep getting the default value. The variable_get works properly when accessed from within a module. Any ideas?

require_once dirname(__FILE__).'/scripts/encrypt.php';

//Include drupal
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
global $base_url;
$base_url = (array_key_exists('HTTPS', $_SERVER) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];


This always returns


1 Answer 1


Why not write a proper Drupal module and include your intended code in there? You miss out on so many of Drupal's nice features if you use it your way, including the issue you are asking about here, but also lots of security and sanity checks. Just sayin'

  • The problem with that is that it needs to be an a file that is accessible from ajax without loading all of Drupals core themes and pages. Do you know of any examples where I can do this?
    – John
    Jul 18, 2014 at 22:43
  • Based on your suggestion it worked by using the following hook_menu: $items['page/update'] = array( 'page callback' => 'data_update', 'access arguments' => array('Update the list'), 'type' => MENU_CALLBACK, );
    – John
    Jul 19, 2014 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.