我们在织梦后台更改文件时,有时会遇到错误提示:DedeCMS:CSRF Token Check Failed,以下是解决办法:

1、打开dede/config.php,找到第63行:

function csrf_check()
{
    global $token;


    if(!isset($token) || strcasecmp($token, $_SESSION['token']) != 0){
        echo 'DedeCMS:CSRF Token Check Failed!';
        exit;
    }
}

global $token;的上一行添加return;,即变为:


function csrf_check()
{
    return;
    global $token;


    if(!isset($token) || strcasecmp($token, $_SESSION['token']) != 0){
        echo 'DedeCMS:CSRF Token Check Failed!';
        exit;
    }
}

2、打开dede/tpl.php,将第93行代码注释掉即可

    if ( empty(${$_csrf['name']}) OR $_csrf['hash'] !== ${$_csrf['name']})
    {
        //exit('Error:no csrf hash code!');
    }