tp5中session缓存多维数组,用原生$_SESSION提示错误

浏览:2964 发布日期:2017/05/19 分类:ThinkPHP5专区 关键字: tp5 session
public function addCart(){
        $id = input('id');
        $shop = Db::table('shop')->find($id);
        $_SESSION['shops'][$id] = $shop;
        $_SESSION['shops'][$id]['num'] = 1;
        //session('shop',$shop);
        //session('shop.num',1);
        $this->success('加入购物车成功',url('index'),3);
        
    }
    public function index(){
        $data = $_SESSION['shops'];
        //$data = session('shop');
        $this->assign('data',$data);
        return $this->fetch();
        
    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>