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. The 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.”
I tried searching on the web for help. There were many articles and threads; however, none of them were very helpful. Few suggest you 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 for the problem. The first step to finding the solution to 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 the error log file. After checking the error logs and their time, I got the information about the file that I need to check. Checking your error log file will help you understand what is exactly causing the issue.
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 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.
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 the issue is fixed.
P.S. Please ensure that you’ve backup of your website before doing anything.