Php Kohana不会读取数据库中的会话数据
几分钟前,我将应用程序的新版本部署到stage实例。尝试登录后,我出现以下错误:Php Kohana不会读取数据库中的会话数据,php,session,kohana,Php,Session,Kohana,几分钟前,我将应用程序的新版本部署到stage实例。尝试登录后,我出现以下错误: Session_Exception [ 1 ]: Error reading session data. [Details: Database_Exception [ ]: ~ MODPATH/database/classes/Kohana/Database/MySQL.php [ 108 ] ] Stackoverflow充满了这些错误,但没有可能的答案帮助我 我的数据库配置文件: <?php defi
Session_Exception [ 1 ]: Error reading session data. [Details: Database_Exception [ ]: ~ MODPATH/database/classes/Kohana/Database/MySQL.php [ 108 ] ]
Stackoverflow充满了这些错误,但没有可能的答案帮助我
我的数据库配置文件:
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'default' => array
(
'type' => 'MySQL',
'connection' => array(
/**
* The following options are available for MySQL:
*
* string hostname server hostname, or socket
* string database database name
* string username database username
* string password database password
* boolean persistent use persistent connections?
* array variables system variables as "key => value" pairs
*
* Ports and sockets may be appended to the hostname.
*/
'hostname' => '127.0.0.1',
'database' => 'MY_DATABASE',
'username' => 'MY_USER',
'password' => 'MY_PASS',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
),
'alternate' => array(
'type' => 'PDO',
'connection' => array(
/**
* The following options are available for PDO:
*
* string dsn Data Source Name
* string username database username
* string password database password
* boolean persistent use persistent connections?
*/
'dsn' => 'mysql:host=localhost;dbname=kohana',
'username' => 'root',
'password' => 'r00tdb',
'persistent' => FALSE,
),
/**
* The following extra options are available for PDO:
*
* string identifier set the escaping identifier
*/
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
),
);
Session::instance在SYSPATH/classes/Kohana/Session.php[54]»Kohana_Session_数据库->中执行以下代码
参数转储$config:
参数转储$id:
以下函数产生从未修改过的错误!:
/**
* Select the database
*
* @param string $database Database
* @return void
*/
protected function _select_db($database)
{
if ( ! mysql_select_db($database, $this->_connection))
{
// Unable to select database
throw new Database_Exception(':error',
array(':error' => mysql_error($this->_connection)),
mysql_errno($this->_connection));
}
Database_MySQL::$_current_databases[$this->_connection_id] = $database;
}
该应用程序在我的本地系统上运行良好。所以我认为这可能是php.ini中的一个错误。这就是为什么我试图在index.php中通过ini_set设置以下内容
ini_set('session.auto_start', 0);
一无所获 尝试在引导文件中设置默认会话适配器
发生这种情况的原因有很多。Kohana-un用它自己的泛型异常有效地隐藏了实际异常。我建议暂时在catch块中抛出原始异常,以查看实际情况 在我的例子中,它来自一个关于mysql的弃用警告以及对mysqli或pdo的需求。因为,我忘了将MAMP PHP模式返回到各个PHP版本
array(4) (
"group" => string(7) "default"
"table" => string(8) "sessions"
"gc" => integer 500
"columns" => array(3) (
"session_id" => string(10) "session_id"
"last_active" => string(11) "last_active"
"contents" => string(8) "contents"
)
)
NULL
/**
* Select the database
*
* @param string $database Database
* @return void
*/
protected function _select_db($database)
{
if ( ! mysql_select_db($database, $this->_connection))
{
// Unable to select database
throw new Database_Exception(':error',
array(':error' => mysql_error($this->_connection)),
mysql_errno($this->_connection));
}
Database_MySQL::$_current_databases[$this->_connection_id] = $database;
}
ini_set('session.auto_start', 0);
Session::$default = 'database';