Support » Fixing WordPress » Changes domain and now I get cookie error

  • Resolved funkytwig

    (@funkytwig)


    When I try to login I get ‘ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.’ I can log in onto a different site on the same server fine. I have tried a different browser (I never logged into the site with) and get the same error.

    Not sure if this is relevant but it’s multisite. I can log in to the master domain and the odd thing is when I go to the dashboard of the site I have changed the domain for it asks me to login again, don’t think it used to.

    PS the site works fine, it’s just the login that does not.

    • This topic was modified 1 year, 1 month ago by funkytwig.
Viewing 15 replies - 1 through 15 (of 19 total)
  • Moderator t-p

    (@t-p)

    This can happen due to several reasons.

    So check error logs for clue or, try Enabling debugging

    Thread Starter funkytwig

    (@funkytwig)

    OK, very odd, I got the following debug.

    As I said the main site is fine, just the login.

    I added

    define( ‘WP_DEBUG’, true );
    define( ‘WP_DEBUG_LOG’, true );
    define( ‘WP_DEBUG_DISPLAY’, false );

    Any ideas?

    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘major’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters
    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘minor’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters
    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘plugins’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters
    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘themes’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters
    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘translations’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters
    [26-Apr-2020 19:29:35 UTC] WordPress database error Table ‘malmesbury_xyz_wordpress.wp_3_auto_updates’ doesn’t exist for query SELECT * FROM wp_3_auto_updates WHERE name = ‘wpemails’ made by require(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, CAU_auto_update->CAU_auto_update_filters

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Using your browser inspector, Look at the test cookie being sent by the login page, and see if the domain or path are incorrect.

    Also check that the “home” and “siteurl” settings are correct for that individual site in the network.

    Thread Starter funkytwig

    (@funkytwig)

    ‘Also check that the “home” and “siteurl” settings are correct for that individual site in the network.’ in the database, they are not in the wp-config.php and what I can work out there is not a wp-config.php for eatch site?

    Thread Starter funkytwig

    (@funkytwig)

    There are no cookies, either when I first go to page or when I login. Inspector->Applications->Cookies does not show anything.

    Thread Starter funkytwig

    (@funkytwig)

    OK, the errors above are a red herring. The table it refers to is for auto update, it seems to be a buf in the auto update plugin. Guess this error was always there but not causing a problem.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    in the database, they are not in the wp-config.php and what I can work out there is not a wp-config.php for eatch site?

    They are in the database. If you are on multisite, you can see these in the Sites portion of the network admin area, as settings for the site. Make sure that these are correct for the particular site having the problem.

    There are no cookies, either when I first go to page or when I login. Inspector->Applications->Cookies does not show anything.

    I don’t want you to look at the cookies, I want you to look at the Response Headers from the request to the wp-login.php URL.

    Open a new Incognito window in Chrome. Open the Inspector and look at the Network tab. Now, go to log in to your site. When you pull up the login form, look at the Network tab again, and find the call to wp-login.php. Look at the Response headers, and find the Set-Cookie for the wordpress-test-cookie, and examine that line. Does the domain and path for the cookie it is trying to set look correct for the site?

    Thread Starter funkytwig

    (@funkytwig)

    OK, maybe I have something.

    So I went to https://malmesburycan.co.uk/wp-login.php in an Incognito tab, went to Network, went to ( clicked on) wp-login.php and clicked on Response tab.

    The only thing I can find on that todo with cookies seems to be:

    <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Log In" />
    <input type="hidden" name="redirect_to" value="https://malmesburycan.co.uk/wp-admin/" />
    <input type="hidden" name="testcookie" value="1" />

    However under Cookies I did find wordpress_test_cookie, with a value of WP+Cookie+check. It has a domain of .malmesbury.xyz. There is a little ! by domain and when I click on it I get ‘This set cookies domain was invalid in regards yo the current hosts url’.

    Is that what I am looking for. malmesbury.xyz is the primary domain I am using for the multisite.

    Thread Starter funkytwig

    (@funkytwig)

    PS I also checked the multisite setup and both site and ‘Site Address (URL)’, Siteurl and home are correctly set to https://malmesburycan.co.uk.

    Did you then try logging in using the malmesbury.xyz domain name? That seems to satisfy things ‘cookiewise’ when I tried it.

    If you haven’t already done this then you might need to add this bit of code to your wp-config.php.

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

    See this article…

    https://wordpress.org/support/article/wordpress-multisite-domain-mapping/#edit-wp-config-php

    Thread Starter funkytwig

    (@funkytwig)

    Tried setting COOKIE_DOMAIN to various things, including this, no joy. Also, the articles that talk about this seem to say it is a solution to do with using the domain mapping plugin, which I do not do (it does not seem to be maintained any more). I just do it using Virtualmin. I have other multi-sites associated with the same primary domain and it works fine.

    Yes, I’m aware that we no longer need the mapping plugin but I’ve heard it still works… But you don’t need it!

    You mentioned Virtualmin…

    The settings in the control panel are mostly for DNS, permitting the domain address, and then ‘mapping’ the domain to the WordPress installation directory…

    Those seem to be right from what I see so Virtualmin is probably out of the picture now.

    Could you share one of the other domains where you can login? Are they all subdomains of malmesbury.xyz by any chance?

    Did you try this though? define('COOKIE_DOMAIN', '.malmesbury.xyz'); // don't omit the leading '.'

    Or maybe this instead? define('COOKIE_DOMAIN', '.malmesburycan.co.uk'); // don't omit the leading '.'

    The above with the

    dot co dot UK TLD

    needs to be double-checked against the other sites should that work for the site in question.

    Thread Starter funkytwig

    (@funkytwig)

    @jnashhawkins just tried both these and no joy. I simply added them to the end of wp-config.php, saved and hit refresh on browser. Think this is what I need to do?

    Thread Starter funkytwig

    (@funkytwig)

    @otto42, any ideas?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Thank you for the domain, this makes it possible for me to see the problem.

    Yes, your cookie domain is incorrect. You can see this in the request to malmesburycan.co.uk/wp-login.php. This cookie header comes back:

    Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/; domain=.malmesbury.xyz; secure

    That ain’t right. The domain here should be the co.uk domain. Cookie won’t work otherwise.

    Now, you’re doing multisite with separate domains, without using any domain mapping plugin or code of any sort. Right?

    Try making a file in wp-content/mu-plugins with this code in it:

    
    <?php
    add_action( 'muplugins_loaded', function(){
    	global $current_blog, $current_site;
    	if ( false === stripos( $current_blog->domain, $current_site->cookie_domain ) ) {
    		$current_site->cookie_domain = $current_blog->domain;
    	}
    });
    

    See if that works. Remove anything that is defining COOKIE_DOMAIN as well. You want this undefined.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Changes domain and now I get cookie error’ is closed to new replies.