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
-
set ADMIN_COOKIE_PATH, COOKIE_DOMAIN, COOKIEPATH, and SITECOOKIEPATH 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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Add below line to your wp-config.php before /* That’s all, stop editing!…*/
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
/* That's all, stop editing! Happy blogging. */
Method 2
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.
Method 3
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.
Method 4
This issue can also be caused by a site_url that doesn’t match the exact URL.
In my case, my site_url and home were //127.0.0.1, which I use to have the flexibility of using http or https, so I did:
// Identify the relevant protocol for the current request
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
// Set SITEURL and HOME using a dynamic protocol.
define('WP_SITEURL', $protocol . '://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', $protocol . '://' . $_SERVER['HTTP_HOST']);
Method 5
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:
yoursite/wp-login.php
Comment following lines 770-773
Code
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."));
else
$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:
yoursite/wp-content/themes/yourthemeFolder/functions.php
Place following code.
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
if ( SITECOOKIEPATH != COOKIEPATH )
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.
Method 6
There could be the following issues in your site.
- Coding Error
- Unnecessary Spaces in Code
- Caching & Security Plugin
Check more here: https://www.scratchcode.io/cookies-are-blocked-or-not-supported-by-your-browser/
Method 7
This happens mainly when you login to backend for the first time.
If you are sure that user and password you’ve entered are valid ones, you can try simply reloading the page and you will be logged in as normal.
And that’s it. After that, your browser will save the required cookie
Method 8
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);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0