0

将 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() 
4

3 回答 3

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);

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

于 2018-01-06T10:48:15.640 回答
0

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

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

于 2015-08-25T21:03:27.597 回答
0

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

于 2015-09-10T13:46:29.170 回答