CodeIgniter Forums
Why I can't retrieve data from session in CodeIgniter3? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Why I can't retrieve data from session in CodeIgniter3? (/showthread.php?tid=62114)



Why I can't retrieve data from session in CodeIgniter3? - hengsopheak - 06-10-2015

Dear Codeigniter.

I've create new web app using Codeigniter3 and I have a problem on session data.

Issue 1: I can't retrieve any data from my session data although it existing in database.

Issue 2  Rows of session table automatically increase and never deleted although I enable sess_expire_on_close to True. And When I refresh pages in Firefox 4 rows of table session will increase the same time. so it will increase to more and more rows if my web pages refresh more and it will increase one by one if I refresh in Chrome browser.

Please check on my configure.

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'tb_session';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

Please check on my attachment to see the increasing of rows when chrome and firefox refresh pages.

And I've also can retrieve any data from table session when I used this method 


Code:
$this->data['f'] = $this->session->userdata('email');



RE: Why I can't retrieve data from session in CodeIgniter3? - InsiteFX - 06-11-2015

For one, your session table doe's not match the CI session table!

PHP Code:
NySQL:
CREATE TABLE IF NOT EXISTS `ci_sessions` (
 
       `idvarchar(40NOT NULL,
 
       `ip_addressvarchar(45NOT NULL,
 
       `timestampint(10unsigned DEFAULT 0 NOT NULL,
 
       `datablob NOT NULL,
 
       PRIMARY KEY (id),
 
       KEY `ci_sessions_timestamp` (`timestamp`)
);