setPrefixedCookie: Can't set cookie, headers already sent!

12 posts by 4 authors in: Forums > CMS Builder
Last Post: July 8, 2016   (RSS)

Hi

I continue to get this issue (seems at random), on this page.  

http://www.geneticalliance.org.au/conditions_detail.php?Cardio-Facial-Cutaneous-Syndrome-93

It is actually a page which Interactive Tools developed for me, so not sure what/why it's happening.  It also continues on from a previous post http://www.interactivetools.com/forum/forum-posts.php?postNum=2236750#post2236750   where this was happening.

Could anyone shed some light on this?

Thankds

Carole

Hi Carole, 

This happens when the server tries to send a header after content has started loading on the page. As the content has started to appear, PHP can't set the page headers anymore. For example if you create a test page with the following content at the top of the document:

<?php
  header("Content-Type: text/html");
?>
<h1>Hello World</h1>

The code above would work, as the headers are sent before content starts loading, but if you had this instead:

<h1>Hello World</h1>
<?php
  header("Content-Type: text/html");
?>

You'd get the error:

setPrefixedCookie: Can't set cookie, headers already sent!

Because content has started to appear on the page, so page headers can't be set anymore. This issue also happens if any content at all starts to load, for example even a new would cause the issue:


<?php  header("Content-Type: text/html");?>

I'd recommend checking over conditions_detail.php and ensuring there is no html or blank spaces before the viewer_functions.php load on the page. I'd also check if any headers are set after the html is displayed.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Greg

There is no space, and <?php header('Content-type: text/html; charset=utf-8'); ?> is the very first line.

I have attached the file - perhaps I am overlooking something else?

Thanks in advance.

Attachments:

conditions_detail.php 13K

Check on line 92 to 94 and change:

?>

<!DOCTYPE html>

to

?><!DOCTYPE html>

That may help.

Cheers,

Tim (toledoh.com.au)

Hi Tim

Thanks for the suggestion.  Tried that but still the same error.  

It appears to have errors with the following, as if the cms code is conflicting with:

<?php include_once("analyticstracking.php") ?> and 

<?php include("genetics_header.php") ?>

Hmmm... does anyone have any suggestions?  Many thanks in advance.

It looks like you may have empty lines in genetics_header.php?

Cheers,

Tim (toledoh.com.au)

No, it's not that either.  It's coming up as the google analytics code which is incorrect.  If I delete that, then it moves to the header.  I honestly think something is conflicting with the code, rather than empty spaces.

????

Im in the office for another 30 mins if you want me to have a look - grab me on skype? tim at toledoh dot com dot au

Cheers,

Tim (toledoh.com.au)

By wolf66 - July 7, 2016

Did you get a fix for this as I have the same issue at present trying to integrate the Membership plugin which I haven't used before.