Warning: session_start(): Session cannot be started after headers have already been sent
session_start() ran after output was sent, so PHP can’t set the session cookie.
Session cannot be started after headers have already been sentsession_start(): Cannot start session Meaning
Sessions need a cookie header, and headers must be sent before any output. A BOM, whitespace before <?php, or an echo/warning earlier in the request causes it.
Common causes
- HTML or whitespace before session_start()
- UTF-8 BOM in an included file
- A PHP notice printed earlier
- session_start() called inside a template
⚡ Quick fix
- Call session_start() at the very top of the entry script
- Remove whitespace/BOM before
<?phpand closing?>tags - Turn display_errors off in production
Detailed fix by platform
PHP
- Move
session_start()into your bootstrap file included first by every page
How to diagnose
- Output start — The warning names the file/line where output started
- Order — Is session_start() the first thing that runs?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026