Errors,Tech,Wordpress

How to fix “ERROR: Cookies are blocked due to unexpected output”

18 Jun , 2014  

How does it feel when you have planned so many things for your day, but you could not do them due to an error? An error can spoil your whole day’s plan and it can be even worse when you do not find its solution. Same thing happened to me. There were so many tasks assigned for the day but got an unexpected error on one of my WordPress websites. It showed blank white page on “wp-admin” and below error on “wp-login.php” page:
ERROR: Cookies are blocked due to unexpected output. For help, please see this documentation or try the support forums.”
Wordpress error
I tried searching on the web for the help. There were many articles and threads; however, none of them were very helpful. Few suggest you to edit your functions.php or wp-config.php file. I could not find a complete solution from any single article as they all were missing parts. So, after getting the error fixed, I thought of sharing the solution with all you out there.
There is no fun of groping around without knowing the reason of the problem. The first step to find the solution of any problem is to understand its reason. The main reason for the above error in WordPress is that one of the active plugins or files like functions.php or any other theme file produces unexpected output, that results in a “headers already sent” warning and consequently preventing WordPress from setting the test cookie on the system.
Now the point is how to find the file that is causing the issue. I tried myself renaming the plugins folder in WordPress via FTP, checked functions.php and other files as they were mentioned in the Google results like wp-config.php, wp-login.php etc., however, none out of them fixed the issue. It already took a lot of my time. Then I thought of checking a file that I should have done at the beginning of the issue; yes, I am talking about error log file. After checking the error logs and their time, I got the information of the file that I need to check. Checking your error log file will help you understand what is exactly causing the issue.
Wordpress Headers already sent error

Update (September 2016): The updated Notepad++ no longer offers this feature so you would need to depend on your hosting company or a professional. If your hosting company isn’t helpful, we strongly recommend using siteground hosting. They will help with any issues like these. Click here to learn more about their plans. They also take care of site transfer so the process is completely hassle free.

The error shows because UTF-8 byte order mark issue that troubles WordPress 3.9 to set test cookie in the most of the cases. When checking your error log file, check the error logs for the date, you started to get the error. In error messages check if it says anything like: “Cannot modify header information – headers already sent by (output started at” and then file path and wp-login.php file’s path and line number. This will confirm you that it is UTF-8 BOM issue and you could locate the file that has got the issue. In my case, it was “custom-posts.php” file. Open the file in Notepad++, which has got the issue. It will show you “Encode in UTF-8” selected under Encoding option from the menu. You need to make sure that you have selected “Encode in UTF-8 without BOM” and it is NOT “Encode in UTF-8”, then click on “Convert to UTF-8 without BOM”, hit enter anywhere in your file and save.
How to convert to utf-8 without BOM
After this refresh your WordPress login page for your website and it will show you the magic. It worked for me; however, in some cases, it can be plugin issue and renaming plugins folder can help. But before making any changes make sure you have checked the error logs so that you know what you are doing. When you know what you are doing, things are a lot easier and you save your precious time, isn’t it?
If you were able to resolve it with some other way, please post it in comments and help other users. In case you are still experiencing this error and need assistance, you may like to contact us and we would be happy to assist you.

Pro tip (Update Feb 7, 2017): If none of the above works, follow the below steps:

  • Check the functions.php file of the theme if that has some extra space at the beginning of the code? If yes, remove that, save the file and check.
  • If not, backup your website, then drag wp-admin, wp-includes folder and all root files except wp-content folder and its files to a backup folder. (don’t lose wp-config.php file in any case)
  • Now download and upload new WordPress’s wp-admin, wp-includes, and other WordPress root files via FTP.
  • Upload wp-config.php file from the old files so that it connects to the database.  Now check if it works.
  • If it still doesn’t, you may ask for our help. I generally fix it for just $19 USD that you could pay via PayPal once issue is fixed.

P.S. Please ensure that you’ve backup of your website before doing anything.

Rajdeep Singh

Article by

If you like this post you may like to stay in touch by following me on social sites. You can also subscribe to this blog via RSS or Email for the latest updates.


12 comments
sami2
sami2

anybody here for help me ?


Magtei
Magtei

Notepad++ no longer has "Convert to UTF-8 without BOM" - however, following this advice to the right file (bp-custom.php) revealed that there was a newline at the start, just like is mentioned in all the suggestions that refer to standard files like wp-config.php

gocare2014
gocare2014

ERROR: Cookies are blocked due to unexpected output. For help, please see this documentation or try the support forums.”

gocare2014
gocare2014

Anybody online to help me out? I have the same problem since yesterday and I am a complete novice ,I have tried all I read but no solution

GKWorlds
GKWorlds

Hi guyes,

Nothing to worry if you faced this error. Access your root folder using ftp client then rename the theme which is using currently & then rename the plugin folder.Now access your www.yourdomain.com/wp-admin.Great success no need to look up log error.After that again rename the theme & plugin as before it was.....

PotluckTV
PotluckTV

Hi! Been living with this issue FOR WEEKS! I am somewhat knowledgeable and still having no success. Worse, more sites of mine are having the issue...one after the other. I will PAY for a solution at this point. it's just unacceptable particularly because it's just 'happening'. Not that I've updated any plugins, sites, etc. AArrrghhhh!!!

Cheers!

Bradleigh
Bradleigh

@PotluckTV -- I got help from a friend of mine who had the brilliant idea to just contact my webhost. It turns out the problem was on their end, so I'd suggest doing that. Hope that helps you... I feel your frustration!

BradleighHuizinga
BradleighHuizinga

Thank you for this article... I'm having this exact issue. I'm a brand new blogger and know nothing about coding, so I don't know how to check error logs, but when I try to log in, five notices like this show up on my login page:

Warning: Cannot modify header information - headers already sent by (output started at /home2/widemead/public_html/wp-content/plugins/adsense-explosion/adsensexplosionopt.php:437) in/home2/widemead/public_html/wp-login.php on line 387


I don't know what notepad++ is or how to open it. But I'm pretty confident the issue is connected to the fact that I'd just downloaded google adsense. I also had just downloaded the 2016 wordpress theme, if that has anything to do with it. 

Any way you can help me, I really appreciate it!!

Thanks in advance.

Rajdeep
Rajdeep moderator

@BradleighHuizinga please email ( rajdeep.singh08@gmail.com ) me the website URL and I will have a look. 

Rajdeep
Rajdeep

wellesley1 your web hosting company may help you with your cpanel login. Please try contacting them as that is crucial to get it resolved.

wellesley1
wellesley1

I am having this problem right now on my site, but cannot logon using FTP nor can I access my cPanel, which means I have no means to diagnose the problem nor apply any suggested corrections.