Fixing "Cookies are blocked or not supported by your browser" in WordPress

Why WordPress says "Cookies are blocked or not supported by your browser" (or "due to unexpected output") when you log in, how its test cookie works and how to fix browser settings, site addresses, COOKIE_DOMAIN, caching and stray output.

If you try to log in to WordPress and get this message instead of your dashboard, WordPress has refused the login because a test cookie it sent your browser didn't come back:

Error: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

A second version means something on the site printed text before WordPress could send its cookies:

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

Both are worded the same in WordPress 7.1.5 and the 7.2 release candidate.1 Despite the wording, your browser often isn't to blame. Common causes include a site that answers on two addresses (with and without www), a wrong cookie setting in wp-config.php, a cached login page, a stray space in a PHP file and security plugins.

"The link you followed has expired" is a different problem, with its own guide.

Every time wp-login.php loads, WordPress sends your browser a small cookie called wordpress_test_cookie.12 It's a session cookie, so the browser usually forgets it when it closes (browsers that restore your tabs may keep it),34 and scripts on the page can't read it.13 The login form carries a hidden testcookie field, so when you click Log In, WordPress knows the cookie should have come back with it. If you aren't already logged in, the check can fail in two ways:1

You see What WordPress found Usual causes
Cookies are blocked or not supported by your browser The form came from the login page, but the test cookie didn't come back with it Browser settings or extensions, a different version of your address, a wrong COOKIE_DOMAIN, a cached login page, a plugin
Cookies are blocked due to unexpected output Something had already sent text to the browser, so WordPress couldn't send cookies at all Spaces or hidden characters in wp-config.php or functions.php, PHP warnings shown on screen, a plugin

The first message replaces any "incorrect password" message, so it says nothing about your password either way. The second can appear as soon as you open the login page, and it always points to the site rather than your browser.

On a single site, WordPress sets the cookie for the paths in your Site Address and WordPress Address (COOKIEPATH and SITECOOKIEPATH) and the domain in COOKIE_DOMAIN, which is blank by default.12 On multisite, both paths come from the network instead.5 A blank domain means the browser only sends the cookie back to the exact address that set it,64 and to a browser, example.com and www.example.com are different addresses.

One handy clue: the page showing the error sends a fresh test cookie of its own.1 So if logging in works on the second try, the first attempt probably came from an old tab, a cached login page or a different version of your address. If it fails every time, look harder at browser settings, COOKIE_DOMAIN and stray output.

Rule out your browser

These checks take a couple of minutes and need no access to the site's files.

  • Try again from the error page. A second attempt often works. If you cleared cookies or restarted the browser after the login page loaded, the test cookie may have gone.
  • Clear this site's cookies, not all your browsing data, or try a private or incognito window, which starts with no stored cookies. WordPress's own documentation suggests clearing cookies first if the error starts after a site move.7
  • Check the browser allows cookies for your site. It's easy to block one site by accident. The page linked from the error message links to cookie help for Chrome, Firefox, Safari and Opera.7
  • Switch off privacy, ad-blocking and cookie-cleaning extensions for your site, one at a time. One that clears cookies on a timer can remove the test cookie before you click Log In.
  • Check the address you're using. An old bookmark or autocomplete can take you to http://, to the www version you don't use or even to an old domain. Use the address shown in your WordPress settings.
  • Try another browser or device. If only one browser fails, the site is fine and the fix lies in that browser.

Check your site addresses

On a single site, under Settings→ General, the WordPress Address (URL) is where WordPress's files live and the Site Address (URL) is the address visitors type in.8 On most sites they're identical. On multisite, each site's address is under Network Admin→ Sites, then Edit under that site.910

The login form sends your details to the WordPress Address.111 So if you open the login page at https://example.com/wp-login.php but the WordPress Address is https://www.example.com, the test cookie is stored for example.com while the form goes to www.example.com, where the browser has no cookie to send. On a single site, the cookie paths come from these settings too,2 so addresses that don't match where the site really lives can send cookies to the wrong place. It's most likely after a move to a new host, a switch to HTTPS or a change between www and non-www.

Compare both fields with the address bar on your home page, including the https:// and whether there's a www. If one is wrong, note down the current values, correct it and save. A wrong value can lock you out, which is why you need the old ones to hand. On a single site, changing the WordPress Address also changes the names of WordPress's login cookies,2 so everyone, you included, is logged out.

If the fields are greyed out, they're set in wp-config.php by WP_HOME and WP_SITEURL, which override the settings screen.129 Check those lines instead, after downloading a copy of the file. If you can't log in at all, you can add those two lines to force the right addresses, as our guide to regaining access to WordPress admin explains.

Then make sure your site only answers on one address. Every other version, such as http:// or the www version you don't use, should redirect permanently to the one in your settings. Most hosting control panels have a setting for this, or your host can do it. Our guide to fixing "Not Secure" warnings covers the HTTPS redirect. Mixing http and https causes login trouble of its own,13 and if you end up with two redirects doing the same job, see fixing redirect loops.

Remove a wrong COOKIE_DOMAIN setting

Download a copy of wp-config.php and search it for COOKIE_DOMAIN. Most single sites don't have this line and don't need it.2

If it's there, it tells browsers which domain the cookies belong to, and browsers ignore any cookie whose domain doesn't cover the address you're on.144 A line like this, left over from a staging site or an old domain, makes every login fail:

define( 'COOKIE_DOMAIN', 'staging.example.co.uk' );

The same goes for www.example.com on a site that's really at example.com. A domain covers its own subdomains but not the domain above it, so example.com works on www.example.com but not the other way round.4

If the domain is wrong, delete the line (or put // at the start), upload the file, clear the site's cookies and log in again. Check for COOKIEPATH, SITECOOKIEPATH and ADMIN_COOKIE_PATH too. WordPress's documentation says these probably shouldn't be set unless other fixes have failed,12 and one copied from another site can point cookies at the wrong folder. If someone set COOKIE_DOMAIN on purpose, for example to share logins across subdomains,13 check with them before removing it.

On a multisite network

Multisite networks that use subdomains set the cookie domain to the network's main domain automatically,5 and a subsite mapped to a completely different domain can't use those cookies. WordPress's multisite documentation says that if you get the cookies error on a mapped domain (or logins fail with no message), add this line to wp-config.php after the lines that set up the network:15

define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] ?? '' );

The handbook's version uses $_SERVER['HTTP_HOST'] on its own. The ?? '' fallback is there because that value isn't set when WordPress runs from the command line, for example under WP-CLI. Either way, the cookie then belongs to whichever domain the visitor is on, plus its subdomains.4 This affects logins on every site in the network, so back up first, test on a staging copy if you can and leave it to a developer if you're unsure.

Stop caches serving the login page

The test cookie is only sent when WordPress actually runs the login page. If a cache hands your browser a saved copy instead, no cookie arrives and the first login attempt fails. The second usually works, because form submissions aren't normally cached (Cloudflare, for one, only caches GET requests)16 and the error page sets a fresh cookie.

WordPress sends the login page with a Cache-Control header containing no-store and private to tell caches not to keep it.171 Cloudflare, for example, doesn't cache HTML pages by default and won't cache a response marked no-store or one that sets a cookie.16 Problems start when a rule overrides that. A Cloudflare cache rule with Edge TTL set to "Ignore cache-control header and use this TTL" caches the page and strips its Set-Cookie header, so the test cookie never arrives.1819 Some caching plugins and server caches have similar "cache everything" options.

To check, open your browser's developer tools (F12, or Cmd+Option+I on a Mac), go to the Network tab and reload the login page. Click the wp-login.php request and look at its response headers:

  • There should be a Set-Cookie header starting wordpress_test_cookie=. If there isn't, WordPress probably didn't run.
  • cf-cache-status: HIT means Cloudflare served the page from its cache.20 Other caches use their own headers, often with "HIT" in the value.
  • In Chrome, the request's Cookies tab shows any cookie the browser blocked, and hovering over the information icon gives the reason.21 That also catches a wrong cookie domain.

To fix it, exclude /wp-login.php from every cache layer, as WordPress's documentation recommends,13 along with /wp-admin/, then clear the caches. If you use a custom login address, exclude that too, because a rule written for wp-login.php won't match it. Our guide to a site not updating explains where caches hide, and your host can check its own server cache.

Fix the "unexpected output" version

This version means something sent text to the browser before WordPress could send its cookies. PHP has to send cookies before any other output, even a single space,3 so the cause is in the site's files, not your browser.

PHP usually leaves a warning naming the culprit, above the login box or in your logs. WordPress's FAQ gives this example:22

Warning: Cannot modify header information - headers already sent by (output started at /path/blog/wp-config.php:34) in /path/blog/wp-login.php on line 42

The part that matters is "output started at", here line 34 of wp-config.php. The file after "in" is only the victim.22 If you can't see a warning, turn on the debug log, load the login page again and search debug.log for "headers already sent".

The usual causes are:

  • Blank lines or spaces before <?php at the top of wp-config.php or your theme's functions.php, often from hand-editing or a pasted snippet. The theme's functions.php runs on the login page too.23
  • Anything after a closing ?> at the end of those files. WordPress's standard wp-config-sample.php has no closing tag,24 and PHP's manual recommends leaving it out of files that end in PHP code so stray blank lines can't creep in after it.25
  • An invisible byte order mark (BOM) at the start of the file, added by an editor saving as "UTF-8 with BOM". PHP treats it as output.26
  • PHP warnings shown on the page, plus notices and deprecation messages when WP_DEBUG is on. Displayed errors count as output.26 With WP_DEBUG on, WordPress reports all of them and shows them by default, because WP_DEBUG_DISPLAY defaults to true.272 With it off, WordPress stops reporting notices and deprecation messages, but warnings still show if the server's display_errors setting is on.27 That's PHP's built-in default, though its recommended production settings turn it off.28 A PHP version update can set this off, because older plugins may suddenly produce new warnings.

For whitespace or a BOM, download the file named in the warning and keep a spare copy. Open it in a plain-text or code editor, not a word processor, and delete anything before <?php on the first line. At the end, delete a closing ?> and anything after it, provided only blank space follows. Save it as plain UTF-8 (not "UTF-8 with BOM"), upload it and try again. If the file belongs to a plugin, update the plugin or contact its developer rather than editing it.

For errors on screen, set WP_DEBUG_DISPLAY to false so they go to the log instead (our debug log guide shows the lines), then deal with the warnings themselves. Switch debugging off and delete debug.log when you've finished. If errors still show with debugging off, ask your host to switch off display_errors.

If this started after a move to a new host, PHP's settings may explain it. Its recommended production settings hold back up to 4,096 bytes of output before sending it, which its own notes say can let cookies be sent after output has started.28 A stray blank line can go unnoticed for years on a server set up that way, then break logins on one that isn't.

Test security and login plugins

Plugins that change the login page are the other usual suspect: ones that move it to a custom address, add two-factor authentication or a CAPTCHA, limit login attempts or act as a firewall. WordPress's own troubleshooting advice for this error includes switching plugins off to test,13 and any plugin can trigger the "unexpected output" version by printing a warning.

If you can still log in from another browser, deactivate suspect plugins one at a time under Plugins and try logging in from the failing browser after each. Visitors lose those features while they're off, so do it at a quiet time or on a staging copy, and switch them all back on afterwards. (The Health Check & Troubleshooting plugin's troubleshooting mode won't help here. It only applies to the browser that switched it on and ends when you log out,29 so it can't show what the failing browser sees.)

If you can't log in at all, connect with SFTP or your hosting file manager, go to wp-content/plugins/ and rename the suspect plugin's folder, for example from plugin-name to plugin-name-off. WordPress can't load a plugin whose files have gone, and deactivates it the next time you open the Plugins screen.3031 Then try logging in again.

  • Renaming a security plugin's folder switches its protection off, including any two-factor login. Rename it back as soon as you've finished testing, reactivate it under Plugins and check its settings.
  • While a login-hiding plugin is off, your login page goes back to /wp-login.php.
  • Renaming a folder affects visitors just as deactivating does, so the same quiet-time advice applies, and rename everything back afterwards.

Once you've found the plugin, update it and check its settings (for example, whether a custom login address is being cached), or contact its developer.

Common questions

Has my site been hacked?

Probably not. This error means a cookie didn't make the round trip between your browser and the site, which normally comes down to settings, caching or the browser. The "unexpected output" version deserves a second look, though. If the file named in the warning contains code you didn't add, especially long scrambled lines at the top of wp-config.php or functions.php, follow our guide to cleaning up a hacked WordPress site.

Do my visitors see this error?

Only people logging in through the WordPress login page can see it, because the check is part of wp-login.php.1 Visitors reading your pages won't. The causes can still affect them, though. A site that answers on two addresses can also make WooCommerce baskets empty between pages, as our add to cart guide explains, so it's worth fixing properly.

Why does it work in one browser but not another?

Each browser keeps its own cookies, settings, extensions and saved addresses. If one browser works, the site is probably fine. Compare the address bar in both, since one may be using www or http:// where the other isn't. Then check the failing browser's cookie settings and extensions, and clear its cookies for your site.

It's unlikely. The WordPress login page doesn't load the scripts that are added to your normal pages,132 and the test cookie is marked so that scripts can't get at it.3 So a banner on your pages normally has no way to touch it. If the error started straight after you installed or changed a consent plugin, deactivating it briefly is a quick way to rule it out.

Still seeing the error?

If you've worked through all of this and still can't log in, my emergency WordPress support can find the cause and get you back in. Many fixes are £50 all in, you'll get a fixed quote before I start and it's no fix, no fee. My maintenance plans test updates on a staging copy before they reach your live site, which is the best place to catch a plugin or PHP change that breaks the login page.


  1. wp-login.php, WordPress source code on GitHub (the same messages are in the 7.1 branch). ↩ ↩ ↩ ↩ ↩ ↩ ↩ ↩ ↩ ↩

  2. default-constants.php (wp_initial_constants and wp_cookie_constants), WordPress source code on GitHub. ↩ ↩ ↩ ↩ ↩ ↩

  3. setcookie, PHP Manual. ↩ ↩ ↩ ↩

  4. ms-default-constants.php (ms_cookie_constants), WordPress source code on GitHub. ↩ ↩

  5. head.c (php_setcookie), PHP source code on GitHub. ↩

  6. Cookies, WordPress Advanced Administration Handbook. ↩ ↩

  7. Migrating WordPress (Changing the Site URL), WordPress Advanced Administration Handbook. ↩

  8. options-general.php, WordPress source code on GitHub. ↩ ↩

  9. network/site-info.php, WordPress source code on GitHub. ↩

  10. wp-config.php, WordPress Advanced Administration Handbook. ↩ ↩

  11. Logging In (Troubleshooting login issues), WordPress Advanced Administration Handbook. ↩ ↩ ↩ ↩

  12. RFC 6265: HTTP State Management Mechanism, section 5.3, IETF. ↩

  13. WordPress Multisite Domain Mapping, WordPress Advanced Administration Handbook. ↩

  14. Default cache behavior, Cloudflare Docs. ↩ ↩

  15. functions.php (wp_get_nocache_headers), WordPress source code on GitHub. ↩

  16. Cache Rules settings (Edge TTL), Cloudflare Docs. ↩

  17. Cloudflare cache responses, Cloudflare Docs. ↩

  18. Network features reference (cookies), Chrome for Developers. ↩

  19. FAQ: headers already sent, WordPress Advanced Administration Handbook. ↩ ↩

  20. wp-settings.php, WordPress source code on GitHub. ↩

  21. wp-config-sample.php, WordPress source code on GitHub. ↩

  22. PHP tags, PHP Manual. ↩

  23. What output is buffered?, PHP Manual. ↩ ↩

  24. load.php (wp_debug_mode), WordPress source code on GitHub. ↩ ↩

  25. php.ini-production (output_buffering and display_errors), PHP source code on GitHub. ↩ ↩

  26. Health Check & Troubleshooting, WordPress.org Plugin Directory, and its troubleshooting mode code on GitHub. ↩

  27. plugin.php (validate_active_plugins), WordPress source code on GitHub. ↩

  28. load.php (wp_get_active_and_valid_plugins), WordPress source code on GitHub. ↩

  29. default-filters.php (wp_enqueue_scripts on wp_head), WordPress source code on GitHub. ↩

Adam usually replies within the hour

Still stuck? Let me fix it for you.

Send me what you're seeing and I'll look at it straight away. Many fixes are £50 all in, you'll get a fixed quote before any work starts, and you only pay once your site is working again.

Pay once it's fixed

VisaMastercardAmerican ExpressPayPal
  • Usually replies within 1 hour often evenings and weekends too
  • Fixed quote upfront many fixes cost £50 all in
  • No fix, no fee pay once it's working
  • 15+ years WordPress experience UK-based, straight to the developer