【问题标题】:CakePHP cannot write to sessionCakePHP 无法写入会话
【发布时间】:2015-04-02 22:08:43
【问题描述】:

当我尝试向会话写入任何内容时,我收到错误 Call to a member function write on null()。我检查了我的 config.php 并且缓存存储在 (/cake/app/temp) 中的目录是可写的。我将其更改为 PHP 设置(将缓存写入 /tmp),这也不起作用。

我可以在标准 PHP 中写入 $_SESSION 变量,但 CakePHP 似乎无法做到这一点,我不知道为什么。

我按照此处的步骤操作,但它们也不起作用: CakePHP 2.1 $this->Session->write is not working

【问题讨论】:

    标签: php session cakephp


    【解决方案1】:

    我想你确定你使用了文件缓存。

    请检查 /cake/app/tmp/cache 和 alle 子目录是否可由用户和运行服务器的组写入。

    如果您在开发环境中,也可以尝试将缓存文件夹中的权限设置为 777。

    将以下代码添加到您的引导文件中:

    Cache::config(
        'default', array(
            'engine'   => 'File',
            'duration' => '+1 hours',
        )
    );
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2011-05-14
      • 2011-05-13
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 2016-03-11
      • 2014-09-10
      • 1970-01-01
      • 2014-10-13
      相关资源
      最近更新 更多