Cannot send session cookie

kenorb - April 23, 2009 - 23:56
Project:Drush
Version:All-Versions-HEAD
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Running drush without arguments:

...
  status                Provides a birds-eye view of the current Drupal installation, if any.
Initialized Drupal 6.9 root directory at /home/wp/public_html/.../public                                   [notice]
Initialized Drupal site default at sites/default                                                                                [notice]
...
  sql cli               Open a SQL command-line interface using Drupalâs credentials.

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/drush/drush/includes/drush.inc:434) in /includes/bootstrap.inc on line 1019
Call Stack:
    0.0005      82860   1. {main}() /home/drush/drush/drush.php:0
    0.0064     677284   2. drush_main() /home/drush/drush/drush.php:26
    0.0156    1151032   3. drush_dispatch($command = array ('description' => 'Print this help message. Use --filter to limit command list to one command file (e.g. --filter=pm)', 'bootstrap' => 0, 'options' => array ('-r <path>, --root=<path>' => 'Drupal root directory to use (default: current directory)', '-l <uri> , --uri=<uri>' => 'URI of the drupal site to use (only needed in multisite environments)', '-v, --verbose' => 'Display all available output', '-q, --quiet' => 'Hide all output', '-y, --yes' => 'Assume \'yes\' as answer to all prompts', '-s, --simulate' => 'Simulate all relevant actions (don\'t actually change the system)', '-i, --include' => 'A list of paths to search for drush commands', '-c, --config' => 'Specify a config file to use. See example.drushrc.php', '-u, --user' => 'Specify a user to login with. May be a name or a number.', '-b, --backend' => 'Hide all output and return structured data (internal use only).'), 'examples' => array ('drush dl cck zen' => 'Download CCK module and Zen theme.', 'drush --uri=http://example.com status' => 'Show status command for the example.com multi-site.'), 'commandfile' => 'core', 'path' => '/home/drush/drush/commands/core', 'engines' => array (), 'command' => 'help', 'callback' => 'drush_command', 'arguments' => array (), 'extras' => array (), 'core' => array (), 'scope' => 'site', 'drupal dependencies' => array (), 'drush dependencies' => array ())) /home/drush/drush/drush.php:65
    0.0156    1151032   4. call_user_func_array('drush_command', array ()) /home/drush/drush/includes/drush.inc:23
    0.0156    1151032   5. drush_command() /home/drush/drush/includes/drush.inc:0
    0.0157    1151064   6. call_user_func_array('drush_invoke', array (0 => 'help')) /home/drush/drush/includes/command.inc:274
    0.0157    1151064   7. drush_invoke($command = 'help') /home/drush/drush/includes/command.inc:0
    0.0160    1151216   8. call_user_func_array('core_help', array ()) /home/drush/drush/includes/command.inc:226
    0.0160    1151216   9. core_help() /home/drush/drush/includes/command.inc:0
    0.0490    2723824  10. drush_bootstrap($phase = 5) /home/drush/drush/commands/core/core.drush.inc:137
    0.0491    2723824  11. _drush_bootstrap_drupal_full() /home/drush/drush/includes/environment.inc:164
    0.0491    2764812  12. drupal_bootstrap($phase = 8) /home/drush/drush/includes/environment.inc:523
    0.0495    2765084  13. _drupal_bootstrap($phase = 4) /home/wp/public_html/dev.wielkapolandia.co.uk/public/includes/bootstrap.inc:971
    0.0499    2799868  14. session_start() /home/wp/public_html/dev.wielkapolandia.co.uk/public/includes/bootstrap.inc:1019
Variables in local scope (#13):
  $conf = array ('domain_bootstrap_modules' => array (0 => 'domain_prefix'))
  $cache = *uninitialized*
  $phase = 4
  $cache_mode = *uninitialized*

How to get rid of this?

I've got at least 8 warnings similar to this.

Line drush.inc:434:

  print str_repeat(' ', $indent) . (string)$message . "\n";

#1

emackn - April 28, 2009 - 20:31

I see the same thing on HEAD

#2

moshe weitzman - May 3, 2009 - 03:47
Status:active» postponed (maintainer needs more info)

cannot reproduce

#3

cdale - May 4, 2009 - 03:11
Version:6.x-2.0-alpha2» All-Versions-HEAD

I get the same thing.

Execute a drush command. Run `drush help [command]` to view command-specific
help.

Examples:
  drush dl cck zen                      Download CCK module and Zen theme.
  drush --uri=http://example.com status Show status command for the example.com multi-site.

Options:
  -r <path>, --root=<path>      Drupal root directory to use (default: current directory)
  -l <uri> , --uri=<uri>        URI of the drupal site to use (only needed in multisite environments)
  -v, --verbose                 Display all available output
  -q, --quiet                   Hide all output
  -y, --yes                     Assume 'yes' as answer to all prompts
  -s, --simulate                Simulate all relevant actions (don't actually change the system)
  -i, --include                 A list of paths to search for drush commands
  -c, --config                  Specify a config file to use. See example.drushrc.php
  -u, --user                    Specify a user to login with. May be a name or a number.
  -b, --backend                 Hide all output and return structured data (internal use only).

Commands:
  dl                    Download core Drupal and projects like CCK, Zen, etc.
  help                  Print this help message. Use --filter to limit command list to one command file (e.g. --filter=pm)
  status                Provides a birds-eye view of the current Drupal installation, if any.
  updatedb              Execute the update.php process from the command line
  sql conf              Print database connection details.
  sql connect           A string for connecting to the DB.
  sql dump              Exports the Drupal DB as SQL using mysqldump.
  sql query             Execute a query against the site database.
  sql load              Copy source database to target database.
  sql cli               Open a SQL command-line interface using Drupal’s credentials.
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 1029
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 1029
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 630
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 631
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 632
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 633
  enable                Enable one or more modules.
  disable               Disable one or more modules.
  uninstall             Uninstall one or more modules.
  statusmodules         Show module enabled/disabled status
  refresh               Refresh update status information
  updatecode            Update your project code
  update                Update your project code and apply any database updates required (update.php)
  info                  Release information for a project
  cron                  Run all cron hooks.
  script                Run php script(s).
  cache clear           Clear all caches.
  watchdog show         Shows recent watchdog log messages. Optionally filter for a specific type.
  watchdog delete       Delete all messages or only those of a specified type.
  sync                  Rsync the Drupal tree to/from another server using ssh.
  eval                  Evaluate arbitrary php code after bootstrapping Drupal.

The warning's don't show up when I use the "-q" option, but I'm not sure if that is just suppressing the warnings, or causing them not to happen.

When I run with the "--verbose" option, I get the following: (The "-v" option does not appear to work as documented)

Execute a drush command. Run `drush help [command]` to view command-specific
help.

Examples:
  drush dl cck zen                      Download CCK module and Zen theme.
  drush --uri=http://example.com status Show status command for the example.com multi-site.

Options:
  -r <path>, --root=<path>      Drupal root directory to use (default: current directory)
  -l <uri> , --uri=<uri>        URI of the drupal site to use (only needed in multisite environments)
  -v, --verbose                 Display all available output
  -q, --quiet                   Hide all output
  -y, --yes                     Assume 'yes' as answer to all prompts
  -s, --simulate                Simulate all relevant actions (don't actually change the system)
  -i, --include                 A list of paths to search for drush commands
  -c, --config                  Specify a config file to use. See example.drushrc.php
  -u, --user                    Specify a user to login with. May be a name or a number.
  -b, --backend                 Hide all output and return structured data (internal use only).

Commands:
  dl                    Download core Drupal and projects like CCK, Zen, etc.
  help                  Print this help message. Use --filter to limit command list to one command file (e.g. --filter=pm)
  status                Provides a birds-eye view of the current Drupal installation, if any.
Initialized Drupal 6.10 root directory at /var/www/html/drupal                                          [notice]
Initialized Drupal site default at sites/default                                                                                [notice]
  updatedb              Execute the update.php process from the command line
  sql conf              Print database connection details.
  sql connect           A string for connecting to the DB.
  sql dump              Exports the Drupal DB as SQL using mysqldump.
  sql query             Execute a query against the site database.
  sql load              Copy source database to target database.
  sql cli               Open a SQL command-line interface using Drupal’s credentials.
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 1029
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 1029
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 630
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 631
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 632
PHP Warning:  Cannot modify header information - headers already sent by (output started at drush/includes/drush.inc:434) in includes/bootstrap.inc on line 633
  enable                Enable one or more modules.
  disable               Disable one or more modules.
  uninstall             Uninstall one or more modules.
  statusmodules         Show module enabled/disabled status
  refresh               Refresh update status information
  updatecode            Update your project code
  update                Update your project code and apply any database updates required (update.php)
  info                  Release information for a project
  cron                  Run all cron hooks.
  script                Run php script(s).
  cache clear           Clear all caches.
  watchdog show         Shows recent watchdog log messages. Optionally filter for a specific type.
  watchdog delete       Delete all messages or only those of a specified type.
  sync                  Rsync the Drupal tree to/from another server using ssh.
  eval                  Evaluate arbitrary php code after bootstrapping Drupal.

I don't know if that will be helpful or not. I'll keep digging and see what I can find.

#4

cdale - May 4, 2009 - 03:15

NOTE: This only seems to affect outputting of the "help" command. Other commands seem to run as expected.

#5

ccshannon - June 5, 2009 - 20:01

I found this thread because of a similar, non-DRUSH problem.

I have a command-line PHP script for importing external content into Drupal via a proprietary XML format. It will run from a cronjob when all is said and done.

When I run from the cli (note I changed some file and path names to protect the innocent):

PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at myscript.php:115) in ./includes/bootstrap.inc on line 1029
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at myscript.php:115) in ./includes/bootstrap.inc on line 1029
PHP Warning:  Cannot modify header information - headers already sent by (output started at myscript.php:115) in ./includes/bootstrap.inc on line 630
PHP Warning:  Cannot modify header information - headers already sent by (output started at myscript.php:115) in ./includes/bootstrap.inc on line 631
PHP Warning:  Cannot modify header information - headers already sent by (output started at myscript.php:115) in ./includes/bootstrap.inc on line 632
PHP Warning:  Cannot modify header information - headers already sent by (output started at myscript.php:115) in ./includes/bootstrap.inc on line 633

FYI, line '115' in 'myscript.php' is a print statement that runs _BEFORE_ I invoke Drupal in my script.

When I move my Drupal invocation ahead of the print statement ... voila, no more PHP Warning!

Somehow line 434 in drush.inc is being executed before the code invokes Drupal bootstrap. Then, when Drupal bootstrap tries to start a session, PHP throws the warning.

#6

moshe weitzman - June 5, 2009 - 20:04
Status:postponed (maintainer needs more info)» fixed

Fixed on Thursday.

#7

System Message - June 19, 2009 - 20:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#8

asb - October 23, 2009 - 13:41

Hi,

now I'm getting this strange error also (latest Drush All-Versions-HEAD from 2009-Oct-23).

Behaviour: Calling 'drush' from within Drupal's site root outputs an Cannot modify header information - headers already sent by...; no command is being executed (excect 'drush sql conf', hmmm...). It simply doews nothing but outputting this error.

Configuration: I'm running several Drupal sites on a dedicated Debian server ('Lenny'). 'drush' is working fine for all other sites, the affected site is quite new, I'm not running other modules than on the other sites.

Workaround: Even if the affected site is working fine, 'drush' seems to reuqire an addition "memory footprint". Increasing the PHP memory limit in settings.php solved the issue (e.g. ini_set('memory_limit', '90M');.

Stepts to reproduce: Take a random D6 site which requires a certain amount on PHP memory which you know of; decrease it in small steps until you find the minimal value where the site still runs fine; at this value, drush will most probably give the Cannot modify header information - headers already sent by... error.

I think this is at least partial a Drush issue since the site runs fine, just Drush requires more memory. If there's no sound way to determine the actual memory requirements, 'drush' could at least capture the error and give a hint to increase the PHP memory limit.

Thanks & greetings, -asb

PS: Feeling lucky to have drush back on the affected site ;)

 
 

Drupal is a registered trademark of Dries Buytaert.