Cookies blocked in wordpress error message.But your cookies are turned on, you’ve cleared them along with the rest of your cache, and the problem exists in every browser!

A typical scenario is when you’ve copied your website from it’s test URL to production, or maybe you’re even just syncing down your prod data to your dev environment, as I do every once in a while to make sure I’m writing code against realistic data sets.  After restoring the copied site files and importing your MySQL database dump into your dev db, you innocently try to navigate to your /wp-admin page and log in.

And you can’t log in because of some weird errors like “Cookies are blocked” on your system … frustrating.

Checklist

When you find yourself unable to log into WordPress, don’t panic.  Just go through the first few logical steps to make sure:

  1. Make sure you’re really at the right URL. No kidding, we all work on a million websites, just make sure your browser didn’t auto-fill your address bar with the wrong URL – it happens, admit it and let your coworkers make fun of you, then go on about your day.You might even be at the correct URL, but your hosts file is redirecting you to a server you’re not expecting.  (Touched your hosts file lately?)
  2. Reset your password.  The forgot password route is super easy, and with as many passwords as we all tend to juggle, it’s probably faster to just reset to something you’ll remember instead of spending an hour trying every combination of letters/numbers/symbols you’ve ever tried to memorize throughout your computing life.
  3. Check for error messages. But beware, error messages can be deceitful.  For example, if you’ve moved or copied your blog to another location with a different URL, you may need to do some blog triage (described further below!).  Also, you might want to try turning WP_DEBUG on in your wp-config.php file, as it may reveal more info that is helpful in troubleshooting.  Remember not to leave this on in production, though!  Read more about debugging WordPress.
  4. Disable your plugins by renaming the plugins folder.  Doing so has minimal impact, and is an attempt to remove any other non-WordPress-Core code from loading and further get to the bottom of your login issues.  Also, try renaming your active theme folder (the folder under the /wp-content/themes directory) to get WP to fall back to the default Twentyeleven theme.You’ll need to go back in and reactivate each plugin later, but is a good troubleshooting step!

This won’t solve every problem out there, but it’s a good start.  In fact, it was when my normal checklist failed and I found a more unique fix for W3 Total Cache issues that I decided to write this post.

W3 Total Cache

If you have W3 Total Cache installed, this could be causing your login problem – especially if you’ve recently moved your blog or otherwise updated it’s URL.  Admittedly, this just sucked 30 mins of life away, so this was one I wanted to share specifically.

W3TC adds and modifies some files which can be problematic, so you probably just want to triage your html_docs folder when moving your blog and using that plugin.  If you’re unable to log into your website, often seeing a “Cookies are blocked” error message as a symptom, you may need to disable and remove the plugin before you can get into the site.  (You don’t need or want a caching plugin in your dev environment, anyway!)

To disable and remove the W3 Total Cache plugin manually:

  1. Navigate to your /wp-content/plugins folder and delete the w3-total-cache folder.
  2. Also, delete the w3-total-cache-config.php file from /wp-content.
  3. Open your wp-config.php file and look for a line of code to comment out or remove:
    define('COOKIE_DOMAIN', 'www.your-website.com'); // Added by W3 Total Cache

    This is the line that causes those confusing cookie errors!

  4. You will still have your settings in your database, and should you choose to re-install the plugin, your settings should still be there.  You could also choose to manually go in and prune the W3TC options from the wp_options table in the database, but it’s not a requirement.
  5. Additionally, I like to go to the Settings > Permalinks options page and just click save again to force WordPress to rewrite the .htaccess file.

If you have further problems, feel free to leave a comment below!  Find another special case of a plugin causing login issues?  Leave a comment and help prevent somebody else’s hair loss  :)

Or, check out one of the following pages where more discussion on the topic has taken place:

Tagged with →  
Share →

4 Responses to When you can’t log into WordPress because your “Cookies are blocked”

  1. punit says:

    I’m facing tthis problem “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.” please help me.

     

    • Is the COOKIE_DOMAIN constant set in your wp-config.php, or any of your theme files? Verify this is not set, or set to the correct domain and sub-domain, by outputting the variable to one of your pages as a test.

      You can also try looking at all of your cookies in Chrome or Firefox and making sure you find various “wordpress_” or “wordpress_logged_in_” cookies with your correct domain and sub-domain.

      And of course, make sure you (or your browser tools, like Chrome Dev Tools or Firebug) have actually disabled cookies in your browser.

      Cheers!

  2. Hi, Ive been having troubles with this,… first, i migrated changes from my pc to a “show” server; the admin side went blank. So Ive googled around for a solution, and tried all the common issues: blank spaces, plugin interference, etc. I’ve never liked the use of plugins, so Ive been cutting down to 3… So, Ive decided to start fresh: deleted the folder on my server, and deleted the tables from my database. Downloaded the latest wp version (3.9.1), installed it to the letter, changed ONLY the critical data on wp-config (server, user, password, and db prefix) and tested, wp worked ok. Went to admin side and nothing. blank screen. Its a fresh install!! so Ive tried again, deleted the folder and created a new one with another name. followed all the steps again, same result. So,I deleted the folder again, the tables and this time downloaded the previous wp version, 3.8.2, installed it and the result, again, is the blank admin page. And WP insists that my cookies are off, I’ve checked (each time) and they are Ok.
    I have two or three sites on that server, I thought that it could be the server; but all the other sites are ok. The htacess? no, it doesnt exists; early this year I had troubles with it, but fixed it for each site.
    Im running out of ideas… or maybe I havent looked throroughly enough…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">