How To Fix Error Warning: session_start(): Cannot send session cache limiter - headers already sent
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.
Hope his helps
# 128755 Reply By banks On Tue Feb 23, 2010 9:00 am
banks
I did face the same problem along time ago when i used to develop with PHP, but now i back to use PHP i face the same problem again and with your help i did get the solution very easily!
Thanks a lot
# 127409 Reply By Noodle On Fri Feb 05, 2010 1:22 am
Noodle
thanks for sharing this.. I also encountered this problem. This tip really works! :)
# 127172 Reply By vtlam On Mon Feb 01, 2010 1:34 am
vtlam
This error display when we change my document encoding = unicode. If we change back encoding = ansi, there no error showed.
# 127028 Reply By Anish On Sat Jan 30, 2010 6:28 am
Anish
am diggin the web for 5hrs n atlast found the solution here..
thank u..
# 124115 Reply By nathan On Wed Dec 23, 2009 3:31 am
nathan
thank u sooo much, it worked i guess no space is needed,,, thanks sooooooooooooooooooooooooo much
# 123378 Reply By Anupam On Tue Dec 15, 2009 3:12 am
Anupam
thanks for the help!
# 122183 Reply By webmaster On Wed Dec 02, 2009 8:44 am
webmaster
you should change it to:
<?php
//store session data
$_session['views']=1;
data
echo "pageviews=". $_session['views'];
?>
<htm
# 122154 Reply By phpbeginner On Tue Dec 01, 2009 11:06 pm
phpbeginner
hi,am having probs executing the php script below :
<html>
<body>
<?php store session data
$_session['views']=1;
session data
echo "pageviews=". $_session['views'];
?>
</bo
everytime i run it i get an error like :
warning: session_start(): cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp1-8\www\session.php in c:\program files\easyphp1-8\www\session.php on line 6
pageviews=1 "
can you enlignten me with the solution and thanks for your help inadvance.
# 120208 Reply By Patrice On Wed Nov 11, 2009 8:24 am
Patrice
thanks so much for explaining this. i was having problems with this error message in my class assignment.
# 118503 Reply By anoop On Thu Oct 22, 2009 9:19 am
anoop
hai , put <?php session_start(); ?>
as the "first line" of the page it fixed the error for me.
# 117387 Reply By John On Wed Oct 07, 2009 6:54 pm
John
yes this did help!
thanks for the post!
# 115127 Reply By Reima On Wed Sep 09, 2009 11:53 am
Reima
i had the same problem when installed a page generator on to existing server. it was very easy to fix after finding your advice. now it works without this warning message. thanks a lot!
# 113597 Reply By Yigit On Sun Aug 23, 2009 1:16 pm
Yigit
don' t include unicode signature (bom) to your php file. in dreamveawer, open page properties then click title/encoding tab. clear the unicode signature checkbox and save file then try again.
# 112419 Reply By Bogdan On Wed Aug 12, 2009 12:30 am
Bogdan
you are sooo right. this helped me alot. i was getting the same error & it turns out i had some spaces after a function.
thank you
# 110210 Reply By Daniel On Wed Jul 22, 2009 8:13 am
Daniel
you are the man! thanks a million times.
# 106716 Reply By Andres On Fri Jun 19, 2009 7:21 am
# 106020 Reply By Csaba On Thu Jun 11, 2009 10:38 pm
Csaba
thx guys, that fixed the problem...remove all lines befor the <?php opening tag, and put the session_start(); to the secont line right after the starting tag...& voila...it works:):)
# 105845 Reply By Behzad On Wed Jun 10, 2009 9:21 am
Behzad
thanks for the post, but i have the same problem and i've deleted all of the white spaces and line breaks before my php tag and its still not working ! the session_start() is in my first line and theres no other chars before that , but i'm still getting that error message !
# 101166 Reply By Tony On Wed Apr 22, 2009 11:34 pm
Tony
i removed the byte order mark (bom) from my textfile, and the warnings disappeared. (had the session start first).
# 99471 Reply By wahyono On Mon Apr 06, 2009 12:21 am
wahyono

<?php
session_start()
?>
diatas ditaruh diatas tag html
# 97250 Reply By Jiew On Sun Mar 15, 2009 7:34 pm
Jiew
put session_start before html tag as herman recommendation workd for me
# 95760 Reply By Herman On Mon Mar 02, 2009 10:25 pm
Herman
put session_start before html tag
# 93631 Reply By Fathi On Wed Feb 11, 2009 7:00 pm
Fathi
even u use the session_start() function in the first line at the header file exampe: header.php and then u call it in another file
php include(header.php) will still return the same warning so to remove the warning u have to to put that function in the first line and dont call the header.php by include function. hope this will help you guys
# 87537 Reply By Filterhead On Thu Dec 25, 2008 12:01 pm
Filterhead
another solution just turn errors off...
error_reporting(0);
do this if you're sure you know and understand php 100%.
# 82404 Reply By TheStalker On Fri Nov 21, 2008 3:53 am
# 82159 Reply By help On Wed Nov 19, 2008 7:18 pm
help
fileformat has to be utf8-withyoutbom!!!!
# 79788 Reply By ivica On Fri Nov 07, 2008 6:21 am
ivica
this problem drive me crazy last 2 hours, until i foun your post. i had an "enter" between two php braces. thanks, man.
# 77847 Reply By Matt On Mon Oct 27, 2008 6:32 pm
Matt
thank you so much. this fixed my problem.
# 76538 Reply By jasperdj On Tue Oct 21, 2008 5:44 am
jasperdj
thanks for taking the effort to make this help tutorial.
i'll try to fix mine ;)
# 75503 Reply By Darryl On Tue Oct 14, 2008 4:36 pm
Darryl
thanks! that took care of my problem. i actually had 2 lines of comments as the first lines on the page. i deleted them and the message disappeared. thanks !!!