This question already has an answer here:
I have a file, which starts <?php session_start();?>
, and it returns an error
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp2\htdocs\index.php:1) in C:\xampp2\htdocs\index.php on line 3
and now take a look at the moment, i can't anderstand anyway when i copy the all content of my file into another file, it start working. can somebody explain how can it happen. thanks
i havent't any white spaces, at least i can't see them
</div>
You probably have some whitespace outside your <?php
tags. Any content outside is sent to the client (including spaces, tabs, newlines, and carriage returns), and once content has been sent, headers cannot be. Starting a session involves sending headers (for cookies).
Be sure to check any files that are including or requiring the file containing session_start()
. The output started at C:\xampp2\htdocs\index.php:1
in your error message tells you exactly where to look (the 1 is the line number).
edit
Looking again at your error message, you're calling session_start()
on line 3. So if you file begins with <?php
on line 3, you've got two newlines and/or carriage returns before then. Note that these might not be visible in your text editor, based on the file encoding, operating system, etc. When you copied the code into a new file, these probably got stripped out.
You probably have some white-space somewhere near the top of your file.
Make sure you're not saving the file with a byte order mark (little/big endian).
check your script with notepad++ and show all character.
or you might want to delete first line and make sure <?php
is at the very top.