First, I used Redis and P3P technology here. Of course, any nosql can satisfy
Impersonate a client that accesses a login.
<?Phpsession_start (); $Get=$_get;if($Get['uname'] =='FTT'&& $Get['Pass'] =='123') {$token=MD5 (rand ()); $_session['User'] ='FTT'; $_session['IsLogin'] =1; Save_redis ($token, Json_encode ($_session)); Header ('p3p:cp= "CURa ADMa DEVa Psao psdo our BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); $file.='<script type= "Text/javascript" src= "http://o3web.demo.com/P3pApi/index?token='. $token.'"reload=" 1 "></script>'; echo $file;}Else{echo'None';} function Save_redis ($keys, $value) {Try{$_redis=NewRedis (); $res= $_redis->connect ('10.10.112.195','6379');}Catch(redisexception $e) {print_r ($e);} $_redis-Set($keys, $value);}?>
The following interfaces are accepted.
<?PHPnamespace_o3web\controller;use Think\controller;/** @desc * @author Carey * @time April 25, 2016 14:50:44 * @ps used for and O3 submission of data*//*the P3P protocol is used to obtain sesion information for O3 logged-in users*/classP3papicontroller extends Basecontroller {/*obtain token tokens for the P3P agreement and write to the cookie*/ Publicfunction Index () {$token= I ('Get.token'); Header ('p3p:cp= "CURa ADMa DEVa Psao psdo our BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); Setcookie ('token', $token, Time () +3600,'/'); } }
I will load it in the init or bese of the page I need.
<?PHP/** Public Controller * @author Carey*/namespace_o3web\controller;use Think\controller;classBasecontroller extends Controller { Publicfunction _initialize () {Load_ext_config ('Configtype', FALSE);//invoking a configuration file$ref= $ This-Set_ref (); $ This->assign ('ref',$ref); /*User login information for O3*/$userinfo=Array (); if(!isset ($_session['UserInfo']) && Empty ($_session['UserInfo'])){//If there is no user information in the session then get the user information in P3ptoken via Redis$userinfo = $ This-P3P (); if(!empty ($userinfo)) {$_session['UserInfo'] =$userinfo; $ This->assign ('Is_uid',1);//if Is_uid is 1 then it is login status}Else{ $ This->assign ('Is_uid',2);//if Is_uid is 2 then there is no login } }Else{ $ This->assign ('Is_uid',2);//if Is_uid is 2 then there is no login } } /*P3P getting O3 user login information*/ Publicfunction P3P () {\predis\autoloader::register (); $a=New\predis\client (); $info= $aGet($_cookie['token']); returnJson_decode ($info, TRUE); }
About sharing P3P instances of cross-domain information