Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.694 diff -u -p -r1.694 common.inc --- includes/common.inc 4 Oct 2007 19:20:39 -0000 1.694 +++ includes/common.inc 4 Oct 2007 22:55:18 -0000 @@ -306,13 +306,15 @@ function drupal_goto($path = '', $query // Before the redirect, allow modules to react to the end of the page request. module_invoke_all('exit', $url); - // Here we register header() to be called after exit(). Because - // session_write_close() was registered before header() all session - // data will be written to the database before the header is sent to the - // browser. - register_shutdown_function('header', "Location: $url", TRUE, $http_response_code); - - // Make sure none of the code below the drupal_goto() call gets executed. + // Even though session_write_close() was registered as a shutdown function, + // we need all session data to be written to the database before the header is + // sent to the browser. + session_write_close(); + header('Location: '. $url, TRUE, $http_response_code); + + // The "Location" header sends a REDIRECT status code to the http + // daemon. In some cases this can go wrong, so we make sure none + // of the code below the drupal_goto() call gets executed when we redirect. exit(); }