tim101011 Posted October 21, 2007 Share Posted October 21, 2007 I get these warnings on most of my sites pages: e.g Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/propertyeagle.co.uk/httpdocs/searchproperties.php:19) in /var/www/vhosts/propertyeagle.co.uk/httpdocs/searchproperties.php on line 43 I have read a lot about these header errors, but never really understood the resolution to the problem. They don't seem to be stopping the site from working in any way, so I am tempted to just down the level of error/warning messages displaying on the actual pages: error_reporting(E_USER_WARNING); Am I being foolish not to resolve the problem? How would actually resolving the problem improve my site? Would it make it quicker? Quote Link to comment https://forums.phpfreaks.com/topic/74217-solved-cannot-send-session-cookie-headers-already-sent/ Share on other sites More sharing options...
MadTechie Posted October 21, 2007 Share Posted October 21, 2007 Line 19 is outputting to the page. this causes the problem.. so move session_start() to the start of the page.. (before line 19) Quote Link to comment https://forums.phpfreaks.com/topic/74217-solved-cannot-send-session-cookie-headers-already-sent/#findComment-374871 Share on other sites More sharing options...
tim101011 Posted October 27, 2007 Author Share Posted October 27, 2007 That didn't work. I think the trouble is that I have HTML code above the PHP code: <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1252"> <title>Propertyeagle.co.uk: Search Properties</title> </head> <body> <p><img border="0" src="logo.GIF" > <font face="Verdana" size="1"> <br> <?php //error_reporting(E_USER_WARNING); session_start(); $tempflag= $_GET['id']; if ($tempflag == '1') { $keywords=$_POST['keywords']; //keywords $keywordscriteria=$_POST['R1']; //keywords criteria $minprice=$_POST['minprice']; //minimum price $maxprice=$_POST['maxprice']; //maximum price $daysposted=$_POST['daysposted']; //how many days back to search $resultsortcriteria=$_POST['R2']; //criteria used to sort results $resultsortcriteriab=$_POST['R2']; //criteria used to fix problem with checkbox not sticking Quote Link to comment https://forums.phpfreaks.com/topic/74217-solved-cannot-send-session-cookie-headers-already-sent/#findComment-379244 Share on other sites More sharing options...
MadTechie Posted October 27, 2007 Share Posted October 27, 2007 no, no, like this <?php /error_reporting(E_USER_WARNING); session_start(); ?> <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1252"> <title>Propertyeagle.co.uk: Search Properties</title> </head> <body> <p><img border="0" src="logo.GIF" > <font face="Verdana" size="1"> <br> <?php $tempflag= $_GET['id']; if ($tempflag == '1') { $keywords=$_POST['keywords']; //keywords $keywordscriteria=$_POST['R1']; //keywords criteria $minprice=$_POST['minprice']; //minimum price $maxprice=$_POST['maxprice']; //maximum price $daysposted=$_POST['daysposted']; //how many days back to search $resultsortcriteria=$_POST['R2']; //criteria used to sort results $resultsortcriteriab=$_POST['R2']; //criteria used to fix problem with checkbox not sticking //Strip any possibly malicous PHP or HTML code out of all te variables used on this page $keywords=strip_tags ($keywords); $minprice=strip_tags ($minprice); $maxprice=strip_tags ($maxprice); $daysposted=strip_tags ($daysposted); Quote Link to comment https://forums.phpfreaks.com/topic/74217-solved-cannot-send-session-cookie-headers-already-sent/#findComment-379248 Share on other sites More sharing options...
tim101011 Posted October 27, 2007 Author Share Posted October 27, 2007 problem solved! you are a genius. Quote Link to comment https://forums.phpfreaks.com/topic/74217-solved-cannot-send-session-cookie-headers-already-sent/#findComment-379251 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.