Edge CPT WordPress Plugin – Error: Cookies are blocked
While performing routine maintenance on a website for a client, I recently found myself unable to login to the site as normal because of the following error:
“ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
Attempts to login simply fail as if you’re entering incorrect credentials. Figuring that this was the result of a plug-in bug, I signed into cPanel and disabled the site’s “plugin” directory just long enough to get signed in to WordPress, then restored the plugin directory to its previous state.
From there I enabled WordPress’s Debug mode by setting its value to true in the config.php file to try to get an idea of what the root of the problem might be. The WordPress config.php file will be found in the root directory of your WordPress installation, at the same level where you see the folders like wp-admin, wp-content, and wp-includes. In the config.php file, look for the line that says:
define( ‘WP_DEBUG’, false );
Setting it to “true” instead of “false” will display errors in WordPress inline. Keep in mind that doing only this will make these errors visible to your sites visitors as well; not just to you in the WordPress dashboard. If you want to see your errors more discretely, you can follow the steps in WordPress’s documentation about Debugging in WordPress. It’s also worth noting that if you have caching tools active on your site (page cache, NGINX, etc.), it’s possible the error messages could be cached as part of your site’s output. So, you should either disable caching before displaying errors, or be sure to clear your cache after displaying them.
I simply displayed the errors long enough to copy and paste them into a notepad, set the config file’s debug status back to “false,” then cleared the caches.
So, what did the error messages have to say?
Warning: Cannot Modify Header Information – Headers Already Sent By
There were multiple occurences of this error, followed by the script line where the error was detected. I’ve included line 1 here just for my demonstration
Warning: Cannot modify header information – headers already sent by (output started at /home/cpanel-site-name/public_html/wp-content/plugins/edge-cpt/core-dashboard/class-edgecoredashboard-theme-validation.php on line 1
Just as I suspected, and as was proven by virtue of being able to sign in with plugins disabled, the error was coming from a plugin. Specifically, in this case the error was coming from the Edge CPT plugin, which is required with this particular site’s theme. I navigated to the class-edgecoredashboard-theme-validation.php file in the specified directory, and at first glance everything seemed to be in order. I did a Google search for “Cannot modify header information – headers already sent by” and found that Kinsta.com had recently posted a great article called “How to Fix the ‘Cannot modify header information’ Error.” Early in the article they provide a short bullet list of common causes, and the first bullet point indicated that “white space before the opening <?php tag or after the final closing ?> tag” can cause this issue.
Sure enough, in a second look at the class-edgecoredashboard-theme-validation.php file, I noticed that the code began on line 2. There was an empty line-break before the opening <?php tag. When I removed the empty line-break and saved the file, I activated debug mode again and found that no errors were returned. After disabling debug mode and clearing the caches one more time, I signed out of the site, and found that the Cookie warning was gone from the login screen, and I was easily able to login like normal. I hope this information helps others who run into the same issue!