Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\project\index.php:2) in C:\AppServ\www\project\sidebar.php on line 34
เหมือนเดิมครับ คราวนี้หน้า index
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\project\index.php:2) in C:\AppServ\www\project\index.php on line 2
โค้ดนะครับ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?session_start();?>
<?
$viewpage=$_REQUEST['viewpage'];
$home_click="";
$showroom_click="";
$webboard_click="";
$contact_click="";
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\project\index.php:2) in C:\AppServ\www\project\index.php on line 2
I was migrating a website from one server to another server. Once I had uploaded all the files to the new server and pulled the website, I kept getting this error at the top of the page:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/includes/myfile.php:1) in /var/www/header_file.php on line 7
when I pulled header_file.php, I had this on line 7:
session_start();
I searched google to see if could find the answer, on one forum I found this thread that said to move the session_start(); to the very top like on line 2 after the
So i did that and it worked, I didn't get the error anymore. But I still questioned as to why it worked on the other server without any errors. The only think I could think of is that on of the includes files i had between line 2-7 had to have a character in the code...
You see, The RULE is you cannot have anything before the session_start(); NOT ONE CHARACTER, otherwise, the browser thinks the webpage has already started, so before you start session_start(); YOU CANNOT START THE HEADER. You start the header with any character, this includes white spaces (space bar)
So I looked in all my include files and sure enough, there was a space before the "
Bottom line is, you can't have any characters display before the session_start() function, otherwise you will get this error.
Sorry for the noob comment but for those having the error :
Warning: session_start(): Cannot send session cache limiter - headers
already sent ...
And before trying all the solutions added by the experts, simply
ensure to have your php code before even the DOCTYPE tag like this
(and not between the doctype and html tags as I was doing):