PHP User
PHP User

Reputation: 2422

Codeigniter doesn't save sessions in database

In config.php

$config['sess_driver'] = 'database';
$config['sess_save_path'] = 'ci_sessions';
$config['sess_cookie_name'] = 'cookiename';
$config['sess_expiration'] = 7200;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
//$config['sess_driver'] = 'files';
//$config['sess_save_path'] = BASEPATH . 'cache/sessions/';

Table:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
    `id` VARCHAR(128) NOT NULL,
    `ip_address` VARCHAR(45) NOT NULL,
    `timestamp` INT(10) UNSIGNED DEFAULT 0 NOT NULL,
    `data` BLOB NOT NULL,
    KEY `ci_sessions_timestamp` (`timestamp`)
);

That doesn't save the session in the database and the API doesn't return any response. If I change it to files it works fine.

[update]

Now I get this error:

Exception: Configured database connection is persistent. Aborting. /var/app/current/system/
libraries/Session/drivers/Session_database_driver.php 94

Upvotes: 0

Views: 526

Answers (1)

Karlo Kokkak
Karlo Kokkak

Reputation: 3714

Take in consideration your dbprefix config.

If it's 'isci_', then your sessions table should be named 'isci_sessions' and sess_save_path the same.

Also you should change your database pconnect config to FALSE to fix the last issue.

Upvotes: 1

Related Questions