【问题标题】:Session helper not found in CakePHP在 CakePHP 中找不到会话助手
【发布时间】:2012-06-20 12:28:47
【问题描述】:

我正在尝试使用 CakePHP 的会话助手,就像在控制器中这样:

$this->Session->write('cart', $cart);

但它不起作用。我收到此错误:

Fatal error: Call to a member function write() on a non-object in ...

在配置文件中启用,我将会话助手添加到控制器和应用控制器

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    原来,你还需要添加Session作为组件,所以AppController看起来像这样:

    class AppController extends Controller {
    
    public $layout = 'website';
    
    public $components = array(
        'Paginator',
        'DebugKit.Toolbar',
        'Session'
    );
    
    public $helpers = array(
        'Html',
        'Js' => array('Jquery'),
        'Session'
    );
    
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-02
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多