PHP checks whether the user has logged on (jump to different pages or perform different actions), and php jumps
1.
2.
<If condition = "$ GLOBALS ['userinfo'] ['user _ id'] gt 0"> <span class = "help_wz"> <a href = "{$ Think. config. VIP_URL}/Member/user_pwd/"style =" color: #404958; "> retrieve logon password </a> </span> <else/> <span class =" help_wz "> <a href ="/Login/FindPwd "style =" color: #404958; "> retrieve the logon password </a> </span> </if>
3. Set global variables in the background and query user information
Public function UserInfo ($ user_id) {// query system information $ System = array ('regionid' => 'system', 'Token' => 'wap ', 'postdetails '=> json_encode (array (); // send the Interface request $ curl = new CurlController () through the curl post method (); $ strs = $ curl-> SendCurl ($ system); $ GLOBALS ['system'] = $ strs ['acctdetails ']; if (empty ($ user_id )) {return false;} setcookie ("login_uid", $ user_id, time () + 3600, "/", C ('cookie _ url'); setcookie ("rdun ", $ this-> authcode ($ user_id. ",". Time (), "ENCODE"), time () + 3600, "/", C ('cookie _ url '));; $ data = array ('regionid' => 'individual', 'Token' => session ('Token '), 'postdetails' => json_encode (array ('user _ id' => $ user_id ,))); // send an Interface request through the curl post method $ curl = new CurlController (); $ str = $ curl-> SendCurl ($ data ); $ GLOBALS ['userinfo'] = $ str ['acctdetails ']; $ newtoken = unserialize ($ str ['acctdetails'] ['Token']); $ oldtoken = unserialize (session ('Token'); if (! Empty (session ('Token '))&&! Empty ($ str ['acctdetails'] ['Token']) {// the user does not have an if ($ newtoken ['user _ id']! = $ Newtoken ['user _ id']) {session ('Token', null); session ('user _ id', null); header ('location: /Login '); return false;} // if ($ newtoken ['time']! = $ Oldtoken ['time']) {session ('Token', null); session ('user _ id', null); header ('location: /Login '); return false;} // timeout cannot be performed here because the value of the session to be saved remains the same. If the user logs on only once, then the problem will occur} return true ;}
The above section describes how to use PHP to determine whether a user has logged on (jump to different pages or perform different actions). I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!