CI Session Configuration by using database

1. Create Table in Default database($this->db), PostgreSQL

CREATE TABLE ci_sessions
(
    id character varying(128) NOT NULL,
    ip_address character varying(45) NOT NULL,
    "timestamp" bigint NOT NULL DEFAULT 0,
    data text NOT NULL DEFAULT ' '::text,
    CONSTRAINT id_ip_address_pk PRIMARY KEY (id, ip_address)
)

2. Adjust session section in config.php file as below

    $config['sess_driver'] = 'database';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 0;   // Zero for terminating session by closing browser.
    $config['sess_save_path'] = 'ci_sessions'; // table name in default database
    $config['sess_match_ip'] = TRUE;    // by IP address
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = FALSE;

3. Adjust cookie section in each config.php file in all main and sub-domain system as below if session needs to be shared with sub-domain system.

    $config['cookie_prefix'] = 'example_';
    $config['cookie_domain'] = '.example.com';
    $config['cookie_path'] = '/';
    $config['cookie_secure'] = FALSE;
    $config['cookie_httponly'] = FALSE;