Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:


I'm trying to start a session for use on a number of pages. I get this error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/dc/keywordeditor.php:8) in /var/www/html/dc/keywordeditor.php on line 15

What am I missing??

TIA Dinesh
  • 2
2 Solutions

must go before ANY output which includes:

- new lines or spaces before the opening php tag (<?php)
- html tags
- php output (including echo and print).

In an ideal situation session_start(); should be placed at the very top of your file before anything else
Also take into consideration the factor of output from any include files you may have, php.net say it best:

QUOTE "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file."


This applies to anything that uses the http_headers, not only session_start (eg the header function and setcookie).
Line 8 of keywordeditor.php would be the line that outputs the stuff.

If you can't move up the session_start(), then use an output buffer around the earlier lines.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now