drupal_bootstrap() allows you to bootstrap Drupal only to a certain level. This is useful if you have functionality running that does not require a full Drupal page cycle. You can choose the level to which Drupal is bootstrapped according to your needs. One of the levels defined is DRUPAL_BOOTSTRAP_SESSION which is defined as "initialize session handling.".

My assumption from reading this would be that the following code would "work":

<?php
  define('DRUPAL_ROOT', getcwd());
  include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
  $_SESSION['some_value'] = true;
  drupal_exit();

However, the above code does not actually send session cookies, as the session is never committed. It turns out that drupal_exit() only commits sessions if Drupal is fully bootstrapped, which seems counter-intuitive with DRUPAL_BOOTSTRAP_SESSION being available.

drupal_exit() should commit the session as long as the bootstrap level is DRUPAL_BOOTSTRAP_SESSION or above, there doesn't seem a solid reason to require DRUPAL_BOOTSTRAP_FULL for this to happen - patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

leewillis77’s picture

leewillis77’s picture

Status: Active » Needs review

Version: 7.32 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.