I am trying to use the session start function but everytime I try to use it, it gives 2 errors:

Cannot send session cookie - headers already sent by (output started at /var/www/form/send.php:11) in /var/www/form/send.php on line 12

Cannot send session cache limiter - headers already sent (output started at /var/www/form/send.php:11) in /var/www/form/send.php on line 12

What could be the problem(s)?

I am running apache2 on Ubuntu and using the netbeans IDE for the programming and testing.
However, when I uploaded it to my website it still gives the same errors(just different pathnames).

8 Years
Discussion Span
Last Post by tokenjoker187

You cannot have any output prior to the session start. Thus, you can't echo anything or have any text coming from any html. If you haven't done this intentionally, it can sometimes be the result of a blank line (e.g. an empty line before the intial <?PHP)


yeah this is like the header("location: sample.php"); you cant have any output before the session_start() even spaces, newline, tab etc. or else it will generate an error


Delete all the files in the tmp directory of the webserver and execute again.

Edited by rajarajan2017: n/a


redirect not working if you have any echo in your page
delete any echo and try again
delete any empty space before <?php ?>


Thanks for the replies... Turns out I had some html (which is still in the php templates when I create new files) tags like <html> <head> and <body>. I deleted all the HTML from the script and works like a charm. Thanks again!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.