PDA

View Full Version : Unable to add cookies, header already sent.


YuGiMoTo
07-24-2014, 02:31 PM
Dear Com,

since last 2-3 days, I am getting this error on my forum.

Unable to add cookies, header already sent.
File: /home/yugitheboss/public_html/forum/forum.php
Line: 2

How can I solve this problem?

Dave
07-24-2014, 02:41 PM
Do the following:

1) In your includes/config.php file, make sure there's nothing in front of the opening <?php tag. No spaces, nothing.

2) If that's alright, disable all of your plugins by adding define('DISABLE_HOOKS', true); after the <?php tag in the includes/config.php file so it looks like:

<?php
define('DISABLE_HOOKS', true);

// Rest of the config file.

Is the error gone? Revert step 2 and then disable your plugins 1 by 1 until you've found which plugin is causing this.

Disco_Stu
07-24-2014, 05:32 PM
I've gotten this so many times. I make a lot of changes to the PHP files and sometimes because of a space character this error comes up. It drives me crazy.

To solve it I restore the file from before the change (I always make a backup first) and then key my changes back in and the problem goes away.

It's a very annoying and common problem that I would think should have been addressed in one of the many patches and upgrades.

YuGiMoTo
07-24-2014, 05:38 PM
I did what you said, but didn't work. I can see the page, only when I visit 1 second the admin panel link.

tbworld
07-24-2014, 05:55 PM
Make sure you are using a proper code editor in editing your scripts. You can inadvertently add a "BOM" and this will initiate this kind of error message.

ForceHSS
07-24-2014, 06:05 PM
<a href="http://notepad-plus-plus.org/download/v6.6.7.html" target="_blank">Notepad++</a>

tbworld
07-24-2014, 06:11 PM
I knew I had a good explanation, that I had sent somebody else, somewhere in my reference files -- it just took me some time to find it. (I did not write it.)

http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

:)