About sharing P3P instances of cross-domain information

Source: Internet
Author: User

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

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.