【问题标题】:Why do not the session Kohana 3.3?为什么没有Kohana 3.3 的session?
【发布时间】:2015-11-19 15:32:43
【问题描述】:

在将 php 从版本 4 更新到 5.5 后,在 Kohana 3.3.3 中停止工作会话。当您调用:Session :: instance ('database') 时出现错误:“读取会话数据时出错。”

这是为什么呢?

Session_Exception [ 1 ]: Error reading session data.

SYSPATH/classes/Kohana/Session.php [ 324 ]

319             }
320         }
321         catch (Exception $e)
322         {
323             // Error reading the session, usually a corrupt session.
324             throw new Session_Exception('Error reading session data.', NULL, Session_Exception::SESSION_CORRUPT);
325         }
326 
327         if (is_array($data))
328         {
329             // Load the data locally

    SYSPATH/classes/Kohana/Session.php [ 125 ] » Kohana_Session->read(arguments)

    MODPATH/database/classes/Kohana/Session/Database.php [ 74 ] » Kohana_Session->__construct(arguments)

    SYSPATH/classes/Kohana/Session.php [ 54 ] » Kohana_Session_Database->__construct(arguments)

    APPPATH/classes/Controller/Base.php [ 17 ] » Kohana_Session::instance(arguments)

    APPPATH/classes/Controller/Index.php [ 9 ] » Controller_Base->before()

    SYSPATH/classes/Kohana/Controller.php [ 69 ] » Controller_Index->before()

    {PHP internal call} » Kohana_Controller->execute()

    SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments)

    SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)

    SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments)

    DOCROOT/index.php [ 118 ] » Kohana_Request->execute() 

【问题讨论】:

    标签: php kohana kohana-3 kohana-auth


    【解决方案1】:

    首先。 检查 php ini 中的会话保存路径,以及保存会话文件的目录权限。就我而言,它是 /tmp。

    转到 /VAR/LOG 并检查 apache 错误日志。

    然后,打开 SYSPATH/application/bootstrap.php 查找

    Kohana::init(array(
        'base_url'   => '/',
        'index_file' => FALSE,
        'errors' => TRUE
    ));
    

    改成

    Kohana::init(array(     'base_url'   => '/',    'index_file' => FALSE,
    'errors' => FALSE ));
    

    你会从你的 php 解释器或 apache 中看到错误。

    如果它没有帮助你。

    找到 SYSPATH/classes/Kohana/Session.php [324] 并替换它

    throw new Session_Exception('Error reading session data.', NULL, Session_Exception::SESSION_CORRUPT);
    

    并将其替换为

    throw new Session_Exception('Error reading session data.'. " [SID:".$id."(".$this->id()."), name:".$this->_name."][Details: " . $e . "]\n", NULL, Session_Exception::SESSION_CORRUPT);
    

    你会发现你的错误。 就我而言,这是数据库错误。

    【讨论】:

      【解决方案2】:

      用php 5.5需要使用模块melancholy,或者PDO,而不是mysql,好吧,或者干脆关掉这些错误输出到index.php

      http://webnotes.by/docs/php/kohana-3-2-and-php-5-5

      【讨论】:

        【解决方案3】:

        在 kohana 的 Session.php 文件中的 catch 块中添加一个 var_dump($e) ,其中正在抛出异常(就像在您粘贴的代码中一样),您会发现真正的问题;)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-10-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-01-27
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多