我正在使用Codeigniter框架来构建一个网站。我收到此错误:
Error Number: 1146
Table 'users.ci_sessions' doesn't exist
SELECT `data` FROM `ci_sessions` WHERE `id` = '5e47bcb40c2954bd7329ff3fbcf253007a0563cc'
Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 166
以下是会话的定义方式: 在config.php中:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_table_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_driver'] = 'database'; // changed from file
$config['sess_save_path'] = 'ci_sessions'; // table name
//$config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_use_database'] = TRUE;
在autoload.php中:
$autoload['libraries'] = array('database','session');
我已阅读https://ellislab.com/codeigniter/user-guide/libraries/sessions.html并按照所有步骤正确访问会话。有关如何修复上述错误的任何建议?
答案 0 :(得分:2)
ci_sessions
表。 错误消息本身告诉您。 答案 1 :(得分:2)
实际上你混合了两个会话驱动程序,即database
和file
,所以如果你想使用文件驱动程序,请阅读官方文档:
http://www.codeigniter.com/userguide3/libraries/sessions.html#files-driver
如果你想使用数据库驱动程序: http://www.codeigniter.com/userguide3/libraries/sessions.html#database-driver
此外,我在自动加载库中遇到了一个奇怪的错误。
请在自动加载阵列中的session
驱动程序之前添加database
驱动程序:
$autoload['libraries'] = array('session','database');
答案 2 :(得分:1)
请注意config.php
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session'; //ci_session don't add 's' in last
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions'; //ci_sessions add 's' in last
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;