phpcodeignitersessionion-auth

table ci_session doesn't exist error


I was trying to configure ion_auth in my codeigniter from this link.As the initial step shown in the tutorial and codeigniter tutorial, I have set the seeion in config.php as below:

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

autoload.php

$autoload['libraries'] = array('session','database');

Created ci_session 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`)
 );

But when I load my codeigniter I get this error:

        A Database Error Occurred
    Error Number: 1146

    Table 'db_platform.ci_session' doesn't exist

    SELECT `data` FROM `ci_session` WHERE `id` = '957v38u8kf237dnsbq5f63345opank6t'

    Filename: D:/xampp/htdocs/platform/system/database/DB_driver.php

    Line Number: 691

I don't know where I am going wrong. I am new to codeigniter session and ion_auth. Can anyone please help me?


Solution

  • There is a Typo in your Table Name because in create table syntax it's ci_sessions,

    CREATE TABLE IF NOT EXISTS `ci_sessions` (
    

    And in the error it's showing error in table name ci_session,

    SELECT `data` FROM `ci_session` WHERE `id` = '957v38u8kf237dnsbq5f63345opank6t'.
    

    So, You are missing s in table name.