简体   繁体   中英

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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