A PHP “headers already sent” warning means output began before PHP tried to send or change HTTP headers. If it appears at session_start(), find the earlier output, then move session initialization ahead of page rendering and remove the unintended output.
What “headers already sent” means
HTTP headers are sent before the response body. A session start may need to send a session cookie or other headers, and PHP cannot add those headers after the response header block has been sent. As the PHP manual explains, “You can’t add any more header lines using the header() function once the header block has already been sent.”
As an Amazon Associate I earn from qualifying purchases.
The warning may say “Cannot modify header information – headers already sent by” or, for a session, “session_start(): Cannot send session cache limiter – headers already sent.” The wording describes the failed header operation; the location named after “output started at” is usually the more useful clue.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRead the two locations in the warning
A typical message points to both where output started and where PHP later tried to send headers. For example:
#1 Best Overall
Warning: Cannot modify header information - headers already sent by (output started at /path/file.php:34) in /path/other.php on line 42
/path/file.php:34: Inspect this first. It identifies where PHP began output./path/other.php:42: This is where the later header operation—such assession_start()orheader()—could not proceed.
Trace what was loaded before that first location, too: included files can produce output before the file containing the session call runs. WordPress’s troubleshooting guidance also recommends interpreting the message this way.
Rank #2
Find what produced the earlier output
At the reported starting file and line, check for visible output as well as characters that are easy to miss. Common causes include:
- Whitespace or a blank line before an opening
<?phptag, or after a closing?>tag. - A UTF-8 byte order mark (BOM) at the start of a PHP file.
- HTML outside PHP code, or
echoandprintcalls that run before session or header logic. - An earlier warning, notice, or error printed into the response.
These are among the causes described in the PHP.earth troubleshooting guide. If the line itself seems harmless, inspect the files it includes and the code that runs before it.
Fix the cause and put header-dependent work first
Move session_start(), redirects, cookie operations, and other work that sends or changes headers ahead of templates and response content. Then remove or correct the earlier output that triggered the warning. The PHP manual’s session_start documentation covers starting a session; the key for this error is that the call must run before output has been sent.
- Copy the complete warning and note both file-and-line locations.
- Inspect the “output started at” location, including whitespace, encoding, output statements, earlier PHP messages, and included files.
- Move session or other header-dependent calls before HTML, templates, and debug output.
- Remove the unintended output, then repeat the request that produced the warning.
Use headers_sent() when the source is unclear
PHP’s headers_sent() function can check whether headers have already been sent and, when available, return the filename and line where output began:
Rank #4
if (headers_sent($filename, $line)) {
error_log("Output started at $filename:$line");
}
Free tools Windows power users keep installed
One-click scans. No signup required.
This is a diagnostic aid, not a replacement for fixing the ordering problem. PHP notes that the filename may be empty if output began before the PHP file ran, such as from a startup error.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When output buffering is—and is not—a fix
Output buffering can defer output from being sent immediately. It can be appropriate when an application deliberately relies on buffering, but adding ob_start() everywhere can conceal premature output and make behavior depend on buffering configuration. Unless buffering is an intentional part of the design, fix the source of the output and the order of operations instead.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




