1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 微信扫码登录验证PHP代码(不用开放平台)

微信扫码登录验证PHP代码(不用开放平台)

时间:2021-11-18 22:16:08

相关推荐

微信扫码登录验证PHP代码(不用开放平台)

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();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。