After a server move, I'm unable to log in to my site. I get the "ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress." error when I try submitting the login form.

I'm positive that my browser supports cookies and that they're not blocked.

I've researched this pretty thoroughly and tried every suggestion I've found:

  • renamed the plugins directory
  • renamed the site theme directory
  • searched the database for instances of the previous URL and replaced those with the new URL
  • updated WordPress to latest version (4.0)
  • defined WP_HOME and WP_SITEURL in wp-config.php

    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', '');
  • tried this hack to wp-login.php: https://wordpress.org/support/topic/cookies-are-blocked-or-not-supported-by-your-browser-1#post-5026171

I can log into the site on my local install, and I can log into the site on our dev server. Any ideas what could be causing this?

  • 1
    Look at the login page's HTML source. Is there anything at all before the initial DOCTYPE line? Even a blank line? If so, then you have some piece of code creating output before the headers are made, in which case this prevents it from setting cookies. – Otto Oct 22 '14 at 20:48
  • 1
    This is due to the fact that Wordpress enforce a $secure_cookie control over an encrpted channel for admin logins. Reconfigure your webserver to enforce SSL/TLS. KR. – user105503 Oct 23 '16 at 12:30
  • If you're using WordPress MU, adding the domain to Domains list in Settings may fix the issue. – Mahdi Taghizadeh Dec 12 '16 at 7:34
  • 1
    This is what worked for me: I changed http to https (added 's') and voila. No more cookie issue. – Prisoner 13 Sep 19 '17 at 21:25
  • @MahdiTaghizadeh - Can you explain what you mean please in more detail? – Greeso Apr 4 at 6:53

Add below line to your wp-config.php before /* That's all, stop editing!...*/


/* That's all, stop editing! Happy blogging. */
  • 1
    This solution also worked for me on a multisite installation. I was able to login to the main site but not to the secondary one. – Be.St. Feb 23 '18 at 12:49
  • @Be.St., try define('COOKIE_DOMAIN', ''); – Steve Apr 18 '18 at 2:14
  • 1
    This didn't work immediately for me, but did on a hard refresh (ctrl + f5 in chrome) – Dave Feb 9 at 22:39

It was Varnish.

Our web host had Varnish set up in a Drupal-specific manner, and it was filtering out the cookies that WordPress uses to handle logins.

  • 1
    In my case it was AWS CloudFront which blocked cookies. – Mantas Sep 8 '16 at 6:37

I have been googled & tried all ways to get rid of this cookie issue. Finally i found two solutions, which could help you.

Solution 1:


Comment following lines 770-773


if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
    $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
    $user = wp_signon('', $secure_cookie);

It might work for some websites and some sites may show blank page. Moreover, this is not recommended,as this file may be overridden after wordpress update so try for second solution.

Solution 2:


Place following code.

 setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
    setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);

Updating of your theme may also loose these changes so please place this code in another functions.php, which is under your child-theme folder in your current active theme. Hope, this will help you.

  • 2
    These are really solutions. More like work arounds, not ideal to use this permanently... – Jake Sep 21 '16 at 18:52
  • -1 for "Solution" 1 because editing the core is NEVER the correct action. 2 will work but it does not identify the issue. – Jeremy Apr 25 '18 at 15:24

I also had this issue recently, it turned out that although the domain name was pointed towards the website, the wordpress multisite didn't have a record in the database to map the domain name to the correct blog, so when wordpress was trying to set the cookies, it was setting the cookie for the subdomain instead of the mapped domain.


I implemented the solution given by wpdevramki and noticed that following issue might surface:

"Notice: Constant COOKIE_DOMAIN already defined in /wp-config.php on line 102"

To resolve this, please comment out the following code in the wp-includes/default-contants.php

if ( !defined('COOKIE_DOMAIN') )
    define('COOKIE_DOMAIN', false);
  • 1
    DO NOT MODIFY CORE CODE! – Jeremy Apr 25 '18 at 15:27

protected by Community Dec 27 '17 at 10:33

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.