public function wxqrcheckAction(){if(g('ajaxchk')!=''){ //前端页面显示二维码并AJAX定时检查已否已扫码验证if(isset($_SESSION['wxqrchk'])){$msg='';if(isset($_SESSION['user'])){$msg=$_SESSION['user']['username'];}$this->ajaxReturn(array('code'=>1,'username'=>$msg));}else{$this->ajaxReturn(array('code'=>0));}die();}else if(g('wxauth')!=''){ //扫码后访问$_SESSION['chksid']=g('wxauth');WXAuthController::Auth('/Public/wxqrcheck/redirect/'.g('wxauth'),1);die("wxauth end...");}else if(g('redirect')!=''){$openid=WXAuthController::GetOpenid(); //获取微信OPENID$user=ORM::for_table('sys_user')->where('openid',$openid)->find_one();if($user){$chksid=$_SESSION['chksid'];session_destroy(); //thinkphp等开始已经session_start了session_id($chksid);session_start();//这个函数必须在session_id()之后$_SESSION['user']=$user->as_array();if($_SESSION['user']['username']=='admin' || $_SESSION['user']['username']=='adminisrator'){$_SESSION['isadmin']=true;}else{unset( $_SESSION['isadmin']);}$_SESSION['islogin']=true;$_SESSION['wxqrchk']=true;echo "扫码登录成功<br/>";}else{echo "没有这个用户 openid:".$openid;}die("手机端验证完成");}else{$sessionid=session_id();$qrurl="/Public/wxqrcheck/wxauth/".$sessionid;$this->assign('qrurl',$qrurl);$this->display();}}
1500字范文,内容丰富有趣,写作好帮手!