• Hi,

    I have WordPress in MU mode at example.com.

    I created a new MU site, at example2.com.

    I have just logged into example.com. When I visit example2.com/wp-admin, I am prompted to login again.

    If I login with the correct username and password, I receive the error:

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

    Cookies are not blocked, and are supported by my browser (Chrome).

    How do I fix this error?

    Thanks,
    Steve.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Bet Hannon

    (@bethannon1)

    It sounds like you have domain mapping enabled, and it is normal expected behavior that you should have to login to the site with the mapped domain, even when you have been logged in as a super admin.

    Generally, you get that message about cookies when you have recently cleared your cookies, and there are none in the browser cache. Simply try logging in again, and you should be able to get yet.

    If you are NOT able to login with that cookies error message, then you may have a plugin or theme conflict. Try:

    -deactivating ALL plugins temporarily to see if this resolves the problem. If this works, re-activate them individually (one-by-one) to find the problematic plugin(s). If you can’t get into your admin dashboard, try deactivating via FTP or SFTP or whatever file management application your host provides. If applicable, also remember to deactivate any plugins in the mu-plugins folder. The easiest way is to rename that folder to mu-plugins-old.
    – To rule out any theme-specific issue, try switching to the unedited default, core-bundled Theme (such as Twenty Twelve or Twenty Thirteen) for a moment using the WP dashboard. If you don’t have access to your admin area, you can switch to the default theme by renaming your current theme’s folder in wp-content/themes and adding “-old” to the end of the folder name using via FTP or SFTP or whatever file management application your host provides. Alternately, you can remove other themes except the default theme. That will force your site to use it.
    – resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems (because the hooks remain unless plugins completely removed or some plugins stick around in cached files. So by renaming the folder, you break them and force them inactive).

    Thread Starter SRD75

    (@srd75)

    Thanks Bet!

    I deactivated all plugins, and the issue remained.

    I am unable to switch the theme, because I cannot login to the affected site’s dashboard.

    I renamed plugins to plugins.old and the issue remained.

    Moderator Bet Hannon

    (@bethannon1)

    If you have FTP access, you can force the site to change to a default theme by:
    1) make sure there is a WP “twentysomething” theme installed. If needed, download one, unzip it, and upload it via FTP.
    2) rename the folder of your active theme.

    But it may not be a theme problem.

    Have you tried totally clearing out your browser cache & cookies?

    Do you get the error message when you try to login with a different computer or browser?

    Potentially could also be server-related. Have you checked error logs?

    Hello SRD75 Member,

    Can you please try by adding below line of code in wp-config.php file

    define('COOKIE_DOMAIN', false);

    Thanks

    Thread Starter SRD75

    (@srd75)

    Great work CT! Fixed the problem.

    Thread Starter SRD75

    (@srd75)

    Hi,

    I’ve run into a similar issue on another MU site, where the network site I’m trying to login to is a different domain to the main WordPress domain.

    I added

    define('COOKIE_DOMAIN', false);

    and now I receive the error:

    The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.

    Thread Starter SRD75

    (@srd75)

    Hi Folks,

    Any ideas on how to resolve this please?

    Thanks, and regards,
    Steve

    Moderator Bet Hannon

    (@bethannon1)

    Hi Steve!

    I’m wondering if defining the cookie domain doesn’t really work with domain mapping. I don’t have time to test it out right now, but I suspect that might be an issue.

    @srd75 I was having the same problem. BetterWP.net mentions COOKIE_DOMAIN in its 10 Useful WordPress Constants and references the /includes/ms-default-constants.php file. I tried commenting out the COOKIE_DOMAIN logic in the function ms_cookie_constants() and that worked for me to get rid of the error. And so did the define('COOKIE_DOMAIN', false); as well as define('COOKIE_DOMAIN', ' '); I think this was a little more help for me to understand what COOKIE_DOMAIN is for, but I’m still not super clear and always feel a little weird doing stuff I don’t sort of understand.

    You might try commenting out out the COOKIE_DOMAIN block all together in that constants file and see if that fixes your error. or try the empty string.

    Thread Starter SRD75

    (@srd75)

    @kaplan, you did it!

    Thank you so much. My project had been held up for so long, now I’m free to proceed.

    Graci.

    @srd75 that’s great! I’ve been looking for more answers on this issue and found a really help post on www.ads-software.com with some details. https://www.ads-software.com/support/topic/howto-domain-mapping-without-a-plugin-instructions/

    This could be another possible fix for the wp-config.php
    define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );

    For me, that sets my cookie domain to the current site’s uri, where the function in the ms-default-constants.php would always return the “main” site instead of a network site domain.

    WP_Network Object
    (
        [id:WP_Network:private] => 1
        [domain] => network-mainsite.dev
        [path] => /
        [blog_id:WP_Network:private] => 1
        [cookie_domain] => network-mainsite.dev
        [site_name] => Main Network Site
    )

    But then define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] ); returns the subsite domain, which is what I’ve been trying to get.
    network-subsite.dev

    The thing that throws me is the original define('COOKIE_DOMAIN', $current_site->cookie_domain); doesn’t return the current subsite, it always gets the main site. But making a change to the ms-default-constants.php code seems like a bad idea as any update would wipe this out.

    if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
      if ( !empty( $current_site->cookie_domain ) )
    
       // the following doesn't get the current subsite, just main 
       // define('COOKIE_DOMAIN', $current_site->cookie_domain);
    
       // the following will get the current subsite
       define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );
    
      else
        define('COOKIE_DOMAIN', '.' . $current_site->domain);
      }
    }
    • This reply was modified 8 years, 3 months ago by kaplan. Reason: added additional information

    I just want to emphasize to future readers the importance of this link that kaplan shared:
    https://www.ads-software.com/support/topic/howto-domain-mapping-without-a-plugin-instructions/

    In short, if you get this…

    The constant “COOKIE_DOMAIN” is defined (probably in wp-config.php). Please remove or comment out that define() line.

    …it means, you have most likely “WordPress MU Domain Mapping” plugin installed for Domain mapping. As Kaplan’s link points out (but I think it didn’t become clear enough) that plugin is no longer required in the newer WordPresses (as of WP 4.x).

    • This reply was modified 8 years, 3 months ago by jgangso.
    infolcd

    (@infolcd)

    While looking around, it seems that there is about a million reasons and solutions for this error; the fix that worked for me was this;
    Go to the ms-default-constants.php file in the includes folder and comment out the COOKIE_DOMAIN logic in the function ms_cookie_constants().
    Hopefully this will help someone else too.

    • This reply was modified 8 years ago by infolcd.

    NO NO NO. DO NOT MODIFY CORE FILES!!!

    Please define the cookie domain. If you modify the core files, the changes will be wiped out after an update. Never suggest modifying the core files.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘WordPress MU cookie issue’ is closed to new replies.