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.
Comment | File | Size | Author |
---|---|---|---|
#1 | commit-sessions-if-session-bootstrapped-2364747-1.diff | 447 bytes | leewillis77 |
Comments
Comment #1
leewillis77 CreditAttribution: leewillis77 commentedComment #2
leewillis77 CreditAttribution: leewillis77 commented