Why my Site Login page in the local test can log in normally, the server but not normal jump?
Reply to discussion (solution)
LoginAction.class.php's Code:
... class Loginaction extends Globalaction {public Function _initialize () {parent::_initialize (); if (isset ($_session[' uid ')) && $_session[' uid '] && strtolower (action_name)! = ' logout ') {$this ->redirect ("Usercontent/index"); }}/** * Displays the login interface */Public Function index () {$back = $_server[' Http_referer ']; if (! $back | | strpos (strtolower ($back), ' login ')!== false | | Strpos (strtolower ($back), ' register ')!== false) { $back = U (' Usercontent/index '); } $_session[' Back ' = $back; $this->display (); }/** * Processing user Login */Public Function login () {$username = I ("Post.name", "', ' trim '); $password = I ("Pass", "', ' Fix_pass '); $c _username = $_cookie[' username '); if ($c _username! = $username) {Setcookie (' username ', $username); } $_session[' Login_time ' = intval ($_session[' login_time ']) + 1; if ($_session[' Login_time ' > 3 && MD5 (I (' Verify ', ' ', ' strtolower ')) = = $_session[' Verify ']) {$this->forwo RD (' Captcha error! '); } if (I ("name") = = NULL | | I ("pass") = = null) {$this->forword (' username or password cannot be null '); } $map ["u_username|u_email|u_phone"] = $username; $map ["u_password"] = $password; $user = M ("user")->where ($map)->find (); $this->dologin ($user); }/** * Execute Login * * @param type $user */Public Function Dologin ($user) {if (!empty ($user)) { if ($user [' u_status ']! = 1) {$this->forword (' User has been frozen '); }//Check to see if ($this->checkedremotelogin ($user [' ID '])) {$this->forword (' Please do not Repeat login! '); } $this->bind ($user [' id ']); $logId = $this->loglogin ($user); $user [' logid '] = $logId; $this->setsession ($user); unset ($_session[' login_time '); unset ($_session[' errormsg '); $back = $_session[' back ']; unset ($_session[' back '); if (! $back) {$back = U (' Usercontent/index '); } if (Strpos (Strtolower ($back), ' Eintro ')!== false) {$back = U (' Fund/asset '); } if (! $back | | strpos (strtolower ($back), ' login ')!== false | | Strpos (strtolower ($back), ' register ')!== false {$back = U (' Usercontent/index '); } header ("Location:".) $back); } else {$this->forword (' User name or password error '); }}/** * bind third-party platform */Public function bind ($uid) {$status 3 = true; if ($_session[' Thirdpartyuserid ') &&! A (' Register ')->hasbind ($_session[' Thrid_party_type ')) {$data [' uid '] = $uid; $data [' third_party_id '] = $_session[' Thirdpartyuserid '); $data [' type '] = $_session[' Thrid_party_type '); $status 3 = M (' Third_Party_bind ')->add ($data); unset ($_session[' Thirdpartyuserid '); unset ($_session[' thrid_party_type '); } return $status 3; /** * Log Logs * * @param array $user * @return type */protected function Loglogin (array $user {$login = D (' login ')->insertlogin ($user); return $login [' insert_id ']; }/** * Set login Session * * @param type $user */protected function setsession ($user) {$_sessio n["username"] = $user ["U_username"]; $_session["UID"] = $user ["id"]; $_session["login_time"] = time (); $_session[' online_time '] = time (); $_session[' logid '] = $user [' Logid ']; }...
URL rewriting does not take effect
URL rewriting does not take effect
Well, why didn't it take effect? Other pseudo-static is in effect.
. htaccess file:
Rewriteengine Onrewritecond%{request_filename}!-drewritecond%{request_filename}!-fRewriteRule ^ (. *) $ index.php?/$ 1 [qsa,pt,l]
Local is Windows7 32-bit +php now environment
Server is LINUX+WDCP server/virtual Host management system
Or maybe the session is invalid.
Problem detected, is the controller's last sentence does not work:
Header ("Location:".) $back);
and $back = '/usercontent-index.html '
This statement somehow can jump locally, but not on the website
It's not good to change it:
$strs = Explode ('. ', $back); $this->redirect ($strs [0]);
The preceding code:
if (! $back) { $back = U (' Usercontent/index '); } if (Strpos (Strtolower ($back), ' Eintro ')!== false) { $back = U (' Fund/asset '); } if (! $back | | strpos (strtolower ($back), ' login ')!== false | | Strpos (strtolower ($back), ' register ')!== false) { $back = U (' Usercontent/index '); }
Wrong!
Http://www.onloan.com.cn/usercontent-index.html
Will go to
Http://www.onloan.com.cn/login-index.html
So either the login program has a problem (cannot be confirmed as a user), or the session fails
Session Save directory can be written?
Fwrite ($FP, ' username: ', $_session[' username ']); This sentence cannot be output
Session Save directory can be written?
What directory is the session saved in?
Session Save directory can be written?
Session.save_path = "/tmp"
The permissions of/tmp are DRWXRWXRWT
I emptied the/tmp directory, restarted the server, or not.
Barley Refueling! Attention, Learning!
\thinkphp\common\functions.php
$name [' path '] = "/runtime"; thinkphp directory under if (Isset ($name [' path ')) Session_save_path ($name [' path ']);
Is that the right thing to say?
The upstairs is not able to log in locally.
Dizzy dead, is the PHP version of the problem, the following same code, local return True, the server returns False,
Track results, same as session empty
protected function IsLogin () {if (!empty ($_session[' username ')) &&!empty ($_session[' uid '])) { $this Updateonlinetime (); return true; } else { return false;} }
$fp = fopen ('./qerr26.txt ', ' w+ '); Fwrite ($fp, ' OK '); Session_Start ();
The result is:
Oksessionxxx:uid:
Strange, Username: no output
Or maybe your server has a low PHP version.
$url = ' http://www.onloan.com.cn/usercontent-index.html ';p rint_r (get_headers ($url)); Echo file_get_contents ($url);
Array ( [0] = http/1.1-OK [1] = Date:sun, 05:57:52 GMT [2] = Content-type:text/ht ML [3] = content-length:265 [4] = Connection:close [5] = = server:nginx/1.0.15 [6] = = X-p OWERED-BY:PHP/5.2.17P1)
Again, your server is using Nginx.
Can you support. htaccess?
Again, your server is using Nginx.
Can you support. htaccess?
Server support. htaccess
My local PHP version is 5.0, debug login No problem
Server PHP is version 5.2, how to change the code? Thank you!
You print the incoming parameters on the login page to see
It's useless to have a blind guess without a goal.
You print the incoming parameters on the login page to see
It's useless to have a blind guess without a goal.
Thank you Moderator,
$map ["u_username|u_email|u_phone"] = $username; $map ["u_password"] = $password;
The contents of both local and server qerr28.txt output are:
Uid:
How can this m method be further traced?
I do not know where to look at trace tracking information, in which directory in which log file?
The code on the 20 floor is wrong and corrected to:
$map ["u_username|u_email|u_phone"] = $username; $map ["u_password"] = $password; $user = M ("user")->where ($map)->find ();
Both local and server Qerr28.txt output:
$user: Array USERNAME:MIKECCN uid:4
In BaseAction.class.php:
protected function IsLogin () {//cjq Add $fp = fopen ('./qerr26.txt ', ' w+ '); fwrite ($fp, ' OK '); $_session[' XXX '] = ' 123 '; Fwri Te ($fp, ' sessionxxx:
Local Qerr26.txt output:
OK sessionxxx:123 USERNAME:MIKECCN Uid:4
Server Qerr26.txt Output:
OK sessionxxx:123 Username:uid:
What is this for? Server cross-page session is missing, what is the cause of this? (Local cross-page session not lost)
What is the value of Session.auto_start in php.ini?
Saving the session variable is not successful, there may be a PHP version problem, for the session environment parameter settings may not be the same, through the php5.0 php5.2 to compare the parameters of the session environment variables.
What is the value of Session.auto_start in php.ini?
Session.auto_start = 0 changed to 1 OK, thank you very much!
Problem with relative paths?
No way