简体   繁体   English

使用Codeigniter在数据库上运行会话的问题

[英]Problems to run session over database with Codeigniter

I'm trying to run all session data over database via table. 我试图通过表在数据库上运行所有会话数据。 But for some reason, it just ignore it when I try to set it up to run via database instead of "files". 但是由于某种原因,当我尝试将其设置为通过数据库而不是“文件”运行时,它只是将其忽略。

Here is my configuration: 这是我的配置:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'sitecookie'; 
$config['sess_expiration'] = 2592000;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

And the table in the database: 和数据库中的表:

CREATE TABLE `ci_sessions` (
 `id` varchar(128) NOT NULL,
 `ip_address` varchar(45) NOT NULL,
 `timestamp` int(10) UNSIGNED NOT NULL DEFAULT '0',
 `data` blob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indeks for tabel `ci_sessions`
--
ALTER TABLE `ci_sessions`
 ADD PRIMARY KEY (`id`),
 ADD KEY `ci_sessions_timestamp` (`timestamp`);

I've tried for hours to figured out where it goes wrong, but without luck. 我已经尝试了几个小时才能弄清楚哪里出了问题,但是没有运气。 Hope somebody have any ideas... 希望有人有什么想法...

I currently using this code it works fine and doesn't have a problem. 我目前正在使用此代码,它工作正常,没有问题。 config 配置

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = TRUE;

and this is the database table. 这是数据库表。

CREATE TABLE `ci_sessions` (
  `id` varchar(40) NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `timestamp` int(10) UNSIGNED NOT NULL DEFAULT '0',
  `data` blob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `ci_sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ci_sessions_timestamp` (`timestamp`);
COMMIT;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM