【问题标题】:cakephp 3.x how to use session in model?cakephp 3.x 如何在模型中使用会话?
【发布时间】:2016-02-01 10:08:37
【问题描述】:

我们正在开发购物车应用程序。我们的应用程序在用户登录时将购物车项目与登录用户合并。所以请你帮我如何在模型中使用 Session

【问题讨论】:

    标签: cakephp cakephp-3.1


    【解决方案1】:

    一种解决方法是使用网络会话对象

    // In Table class include this line at the top
    use Cake\Network\Session;
    
    public function getSession(){
       $session = new Session();
       debug($session->read()); die;
    } 
    

    我不知道这是否是最佳解决方案。其他方法在这里讨论Session accessibility in model and behavior

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 1970-01-01
      • 2017-11-26
      • 1970-01-01
      • 2016-11-07
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      相关资源
      最近更新 更多