CodeIgniter Forums
Session database error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Session database error (/showthread.php?tid=62822)



Session database error - nielscil - 08-30-2015

Hello I've got a problem with my codeigniter 3 setup. When I log in on the site from IP x and then I'm trying to go to site from IP y I got an error message:

Code:
Error Number: 1062

Duplicate entry '----' for key 'PRIMARY'

INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('----', '----', 1440958363, '__ci_last_regenerate|i:1440958363;')

Filename: libraries/Session/drivers/Session_database_driver.php

Line Number: 220

My session config:

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

And my database table:

Code:
CREATE TABLE IF NOT EXISTS `ci_sessions` (
 `id` varchar(40) NOT NULL,
 `ip_address` varchar(45) NOT NULL,
 `timestamp` int(10) unsigned NOT NULL DEFAULT '0',
 `data` longblob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `ci_sessions`
 ADD PRIMARY KEY (`id`),
 ADD UNIQUE KEY `ci_sessions_id_ip` (`id`,`ip_address`),
 ADD KEY `ci_sessions_timestamp` (`timestamp`);

Do you guys know how to fix this?


RE: Session database error - PaulD - 08-31-2015

Does it happen if you set the config sess_match_ip to FALSE?


RE: Session database error - Narf - 09-01-2015

https://github.com/bcit-ci/CodeIgniter/commit/20573bd472bdeaa831074e563f239585554ffaf5


RE: Session database error - nielscil - 09-04-2015

(08-31-2015, 03:20 PM)PaulD Wrote: Does it happen if you set the config sess_match_ip to FALSE?

No, if I disable this option it works right. But using match ip is safer right?