I found this error repeated several times for two of the pages on my website.

    Warning: Cannot modify header information - headers already sent by (output started at 
/home/customer/www/mydomain.com/public_html/includes/common.inc:2800) in user_cookie_save() (line 4041 of 

I checked a bit around and found other similar errors with "Headers already sent" but none of them on the user_cookie_save function.

How can I debug fix it?

I'm running on Drupal 7.78, PHP and as modules that could influence the cookies, I'm running just the EU Cookie compliance module.

What I find strange, is that I do not recall having seen this error before. There is a small chance that the error was there ad I did not see it because the logs are filled with page not found, and access denied errors by nice persons from the internet :) I would say though that that is a small chance as I've checked many times the logs in the past and did not see this error.

I have no idea what changed, and also no idea of what is the impact of this error, it's a warning, but I can't reproduce it.

Many thanks

1 Answer 1


HTML requests return headers, that tell what the response will be, and the body, that is the response. The headers are required by browsers to understand how to interpret the data that is in the body, therefore no output must be sent before the headers. This error is outputted when headers are sent after some body output has been sent. When working on a Drupal system, there are three common causes to this error that you can debug:

  1. An echo statement in a module/theme (and not in a template). Sometimes developers will echo out a value for debugging purposes, and forget to remove that line.

  2. Blank space before the opening <?php tag in a document on the system. This is usually in a custom module or theme, or can be in settings.php, or settings.local.php.

  3. A closing `?>' tag, with whitespace after it. Drupal coding standards are to not use the closing php tag, so if you find this anywhere outside of a template, you can probably remove the closing tag. At the very least, you should ensure there is NO whitespace after the tag.

  • Thank you Jaypan, Your answer is generic enough, as I guess from the information I provided you cannot infer more. Shall I understand that the user_cookie_save function does not have any problem? and that the problem is not there? I've checked the logs today and the error did not happen again and that particular page where it happened is accessed hundreds of times / day. To search for all the modules whether the above 3 rules are consistently applied it's an enormous task. I'm puzzled why it happens so randomly and less frequently
    – MMT
    Commented Mar 21, 2021 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.