Accessing variable_get when loading bootstrap from an external file 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
$currdir=getcwd();
define('DRUPAL_ROOT',$_SERVER['DOCUMENT_ROOT']);
chdir(DRUPAL_ROOT);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
global $base_url;
$base_url = (array_key_exists('HTTPS', $_SERVER) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'];
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

print_r(variable_get('var_name',DEFAULT_VAR_NAME));


This always returns

DEFAULT_VAR_NAME
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'