今天将服务器上的PHP版本升级到最新后,发现有一个织梦CMS的网站后台进不去,输入用户名和密码进去后一片空白,也不显示错误,后来在网上找到解决方法,拿来做个备忘。
问题是出现在session上面,找到include/userlogin.class.php,里面有一个keepuser()函数,它是用session_register来注册一个session变量,但是在php5.4以后的版本中已经移除了这个功能,所以必须修改代码。
打开include/userlogin.class.php,查找到@session_register($this->keepUserIDTag); 注释掉,然后改为if (!isset($_SESSION[$this->keepUserIDTag]))一共有六个,全部改为下面这样:
if (!isset($_SESSION[$this->keepUserIDTag])) //@session_register($this->keepUserIDTag); $_SESSION[$this->keepUserIDTag] = $this->userID; if (!isset($_SESSION[$this->keepUserTypeTag])) //@session_register($this->keepUserTypeTag); $_SESSION[$this->keepUserTypeTag] = $this->userType; if (!isset($_SESSION[$this->keepUserChannelTag])) //@session_register($this->keepUserChannelTag); $_SESSION[$this->keepUserChannelTag] = $this->userChannel; if (!isset($_SESSION[$this->keepUserNameTag])) //@session_register($this->keepUserNameTag); $_SESSION[$this->keepUserNameTag] = $this->userName; if (!isset($_SESSION[$this->keepUserPurviewTag])) //@session_register($this->keepUserPurviewTag); $_SESSION[$this->keepUserPurviewTag] = $this->userPurview; if (!isset($_SESSION[$this->keepAdminStyleTag])) //@session_register($this->keepAdminStyleTag); $_SESSION[$this->keepAdminStyleTag] = $adminstyle;