I am creating one website using codeigniter with session. When i load the welcome page in codeigniter its showing the error like:-
Error Number: 1054, Unknown column 'data' in 'field list', SELECT data FROM ci_sessions WHERE id = '562a04f4kt6j4n6eehsob3vm3puuc3r5', Filename: C:/xampp/htdocs/ci_ecom/system/database/DB_driver.php, Line Number: 691.
I call the session library and database library in auto load area corretly. I dont know exactly where i did the mistake I check it in C:/xampp/htdocs/ci_ecom/system/database/DB_driver.php this path area also.. In my table I put the column name user_data but here its showing Unknown column 'data' in 'field list'.
this is my table stucture
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
This is my ci session
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
any one can u pls help what is the exact problem...
A straight forward answer is to create the table in this format,
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(40) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
PRIMARY KEY (id),
KEY `ci_sessions_timestamp` (`timestamp`));
and everything should go fine. It's because the session table structure is modified in the latest versions of codeigniter.
I believe you'd experience this problem in CodeIgniter 3.X. To resolve it: Update the config.php to look like 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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With