Dedecms v5.7 using session_register () in php5.4 or above cannot log on to the background, and the page is not displayed

Source: Internet
Author: User

I want to try zhimeng's product and download dedecms v5.7. After local deployment, when you log on to the background correctly, the page does not display any output or display (displayed only when the logon or password is incorrect), and no error is reported. Go to script debugging and find that the problem lies in the following part of the login. php logon page.

Login. php

... $ Cuserlogin = new userlogin ($ admindir); If (! Empty ($ userid )&&! Empty ($ PWD) {$ res = $ cuserlogin-> checkuser ($ userid, $ PWD); // success if ($ res = 1) {$ cuserlogin-> keepuser (); // No output if (! Empty ($ gotopage) {showmsg ('successfully logged on, is switching to the Management Homepage! ', $ Gotopage); exit ();} else {showmsg (' successfully logged on, switching to the Management Homepage! ', "Index. php"); exit ();} echo "OK ";}...

To the script userlogin. Class. php that encapsulates the userlogin class (path./include/), the keepuser () method code used is as follows:

Userlogin. Class. php

...function keepUser(){if($this->userID != '' && $this->userType != ''){global $admincachefile,$adminstyle;if(empty($adminstyle)) $adminstyle = 'dedecms';@session_register($this->keepUserIDTag);$_SESSION[$this->keepUserIDTag] = $this->userID;@session_register($this->keepUserTypeTag);$_SESSION[$this->keepUserTypeTag] = $this->userType;@session_register($this->keepUserChannelTag);$_SESSION[$this->keepUserChannelTag] = $this->userChannel;@session_register($this->keepUserNameTag);$_SESSION[$this->keepUserNameTag] = $this->userName;@session_register($this->keepUserPurviewTag);$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;@session_register($this->keepAdminStyleTag);$_SESSION[$this->keepAdminStyleTag] = $adminstyle;PutCookie('DedeUserID', $this->userID, 3600 * 24, '/');PutCookie('DedeLoginTime', time(), 3600 * 24, '/');$this->ReWriteAdminChannel();return 1;}else{return -1;}}

If @ is removed, session_register () reports an error:
Call to undefined function session_register ()
Confirmed the problem. The manual is described as follows:
"Version: (PHP 4, PHP 5 <5.4.0 )"
"This function has been removed from PhP 5.3.0 and has been removed from PhP 5.4.0. "

View Manual

Session_register () is redundant in later versions of php5.4. Instead, you can directly use $ _ session ['abc'] = "";

View the problem about this method in stack overflow.

Solution: Remove or comment out all session_register () and save the $ _ Session array directly.

Keepuser ()

...//session_register($this->keepUserIDTag);$_SESSION[$this->keepUserIDTag] = $this->userID;//session_register($this->keepUserTypeTag);$_SESSION[$this->keepUserTypeTag] = $this->userType;//session_register($this->keepUserChannelTag);$_SESSION[$this->keepUserChannelTag] = $this->userChannel;//session_register($this->keepUserNameTag);$_SESSION[$this->keepUserNameTag] = $this->userName;//session_register($this->keepUserPurviewTag);$_SESSION[$this->keepUserPurviewTag] = $this->userPurview;//session_register($this->keepAdminStyleTag);$_SESSION[$this->keepAdminStyleTag] = $adminstyle;...

After modification, it will be displayed normally.

I downloaded the "latest" version from the zhimeng homepage. Is it strange that no one has encountered the same problem. Since this problem can occur, other parts cannot guarantee that there will be no more such hidden risks.

This article is also published in my independent blog. mc-zone.me, click to visit this article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.