Skip to content
Advertisement

WordPress admin login cookies blocked error after moving servers

Background: had a working WordPress 3.7 site at olddomain.com.

I moved it to newdomain.com successfully, and in the process added this to wp-config:

define('WP_HOME','http://newdomain.com');
define('WP_SITEURL','http://newdomain.com');

Now when I attempt to login from newdomain.com/wp-admin I’m getting the cross-browser error (despite having cookies enabled and clearing existing cookies):

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

I tried going into wp-login.php and commenting out the following lines (744-747) to stop the conditional testcookie check

    // If cookies are disabled we can't log in even with a valid user+pass
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);

but doing that leaves me stuck in a redirect loop back to the admin page:

http://myapp.com/wp-login.php?redirect_to=http%3A%2F%2Fmyapp.com%2Fwp-admin%2F&reauth=1

Do I need to change (or not set) the site URL? or is there another potential way to troubleshoot this? thanks

Advertisement

Answer

Having migrated hundreds of WP sites, here’s a few thoughts :

If migrating the DB : Check the database options table (probably wp_options) column “option_name” that values “siteurl” and “home” have the correct “option_value” for your site. “siteurl” is huge.

I can testify that the options table tweak is the bare minimum required to migrate a DB to a new domain in WP. (will not cause redirection, will still have issues)

WP looks up these DB options to serialize the site to domain and I am pretty sure the defines are lower in the stack and of no help. Consider the wp-admin activities as loosely coupled to the front. You can break everything (done it) in the front and the admin will still function.

Also – did/does the site work with generic install/no migration or tweaks?

As mentioned – .htaccess (missing or misconfigured) will cause your error. Regarding the .htaccess file, if used, this is a dot.file and many operating systems will “ignore” or “make invisible” so a copy/paste or FTP application or similar may not carry the .htaccess

(pretty sure on this) If you moved the DB and used pretty urls, and missed the .htaccess that could be all you need to fix. I just tested locally on a sandbox install and the table wp_option column “option_name” value “permalink_structure” when left blank in column option_value will return to ?p=1 (non-permalink) status and .htaccess will be mostly bypassed.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement