Wordpress admin login cookies blocked error after moving servers

后端 未结 15 1780
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 14:13

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:

         


        
相关标签:
15条回答
  • 2020-12-24 14:18

    I had the same problem and nothing works. After upgrading my php 5.3.x to 5.4.x it works fine.

    0 讨论(0)
  • 2020-12-24 14:21

    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.

    0 讨论(0)
  • 2020-12-24 14:25

    Following step solve my issue

    on wp-config.php

    //define('WP_CACHE', true); // Added by W3 Total Cache Block this line
    //define("COOKIE_DOMAIN", "www.domain.com"); Block this line
    

    Delete following files from wp-content

    object-cache.php 
    advanced-cache.php
    db.php
    
    0 讨论(0)
  • 2020-12-24 14:26

    Assuming you are running on a Unix/Linux type platform - please ensure you have copied your .htaccess file from your original server and updated any references to the old domain within that file. It will be in the root of your wordpress deployment (if you are using it).

    Either that or you may have a reference to your old domain somewhere in your wp_options table within the database.

    Be forewarned that as you have moved from one domain to another, images and media locations within posts may need to be updated. You can either do that yourself directly within the database, use a find/replace utility or manually re-point your images within your posts. An alternative method to fix your post data is to export all your posts from your old site (from within the admin panel) - Tools > Export > All posts; then manually update the URL within that resultant file before importing to your new site.

    All of this and much more is covered over at codex.wordpress.org. For more information see this link:

    http://codex.wordpress.org/Changing_The_Site_URL

    IMPORTANT NOTES:

    1. If you are going to modify anything directly within the database, make sure you read the section that talks about GUIDs

    2. If you are using Better WP Security, there are other things you may need to do, but based on what you are describing, I doubt you have it installed.

    0 讨论(0)
  • 2020-12-24 14:27

    I created my Multisite install long ago when you needed a plugin for domain mapping. So I had the file '/wp-content/sunrise.php' and in the wp-config define( 'SUNRISE', 'on' ); It's been working just fine until a recent update to WordPress.

    I viewed these errors in my debug.log:

    Undefined index: HTTP_HOST in ../public_html/wp-content/sunrise.php on line 10
    Undefined index: HTTP_HOST in ../public_html/wp-includes/ms-settings.php on line 57
    

    So I deleted the sunrise file and wp-config sunrise definition and added @max4ever/@duck_boy's cookie definitions to the wp-config file:

    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', ''); 
    

    That solved the problem. I can now login!! Note: I tried this definition and it worked as well. Taken from Multisite Setup Guide

    define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );
    
    0 讨论(0)
  • 2020-12-24 14:28

    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.

    0 讨论(0)
提交回复
热议问题