在微信公众平台开发中 为什么在一个模块下的2个控制器中同一个session不能用
<code>//网页授权获取用户基本信息 public function webUsers(){ $token=session('token'); $wechatAuth=new WechatAuth($this->appId,$this->appSecret,$token); //$wechatAuth=$this->wechatAuth; if($_GET['iscode']){ $url="http://hdzs.zhed.com/index.php/Activity/index"; $result=$wechatAuth->getRequestCodeurl($url); header("Location:{$result}"); }else if($_GET['code']){ header('Content-type:text/html;charset=utf-8'); $users=$wechatAuth->getAccessToken('code',$_GET['code']);//疑惑语句 $User=M("User");//实例化user对象 $openid=$users['openid']; session('openid',"$openid");//将用户的openid存入session中</code>
<code>public function users($wechat,$data){ $openid=$data['FromUserName']; //session(null); // session('openid',"$openid"); //$wechatAuth=$this->wechatAuth;//实例化 $wechatAuth对象 ///$user=$wechatAuth->UserInfo($openid); $text="你的用户名是:". session('openid'); $this->logger("发送用户消息".$text); //$wechat->replyText($text); }```</code>
在微信公众平台开发中 为什么在一个模块下的2个控制器中同一个session不能用
<code>//网页授权获取用户基本信息 public function webUsers(){ $token=session('token'); $wechatAuth=new WechatAuth($this->appId,$this->appSecret,$token); //$wechatAuth=$this->wechatAuth; if($_GET['iscode']){ $url="http://hdzs.zhed.com/index.php/Activity/index"; $result=$wechatAuth->getRequestCodeurl($url); header("Location:{$result}"); }else if($_GET['code']){ header('Content-type:text/html;charset=utf-8'); $users=$wechatAuth->getAccessToken('code',$_GET['code']);//疑惑语句 $User=M("User");//实例化user对象 $openid=$users['openid']; session('openid',"$openid");//将用户的openid存入session中</code>
<code>public function users($wechat,$data){ $openid=$data['FromUserName']; //session(null); // session('openid',"$openid"); //$wechatAuth=$this->wechatAuth;//实例化 $wechatAuth对象 ///$user=$wechatAuth->UserInfo($openid); $text="你的用户名是:". session('openid'); $this->logger("发送用户消息".$text); //$wechat->replyText($text); }```</code>
<code>session(null);</code>
session(null); //已经把session清空了. 当然下面就拿不到了