php - tp框架中的session 问题
大家讲道理
大家讲道理 2017-04-10 17:52:50
[PHP讨论组]

在微信公众平台开发中 为什么在一个模块下的2个控制器中同一个session不能用

//网页授权获取用户基本信息
    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中
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);
    }"
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(2)
怪我咯
session(null);
PHPz

session(null); //已经把session清空了. 当然下面就拿不到了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号