CodeIgniter Forums
set_userdata doesn't realy set userdata - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html)
+--- Thread: set_userdata doesn't realy set userdata (/thread-1252.html)



set_userdata doesn't realy set userdata - bboom - 02-23-2015

Hi,

I'm using a modified version of the very basic user authentication library (https://github.com/joelvardy/Basic-CodeIgniter-Authentication) for the authentication in my application.

It was working well until I did an upgrade to CI3 RC2, after that upgrade the userdata isn't set.

PHP Code:
$user_details $user->row();
 
// Set the userdata for the current user
$this->ci->session->set_userdata(array(
'identifier' => $user_details->identifier,
'username' => $user_details->email,
'logged_in' => $_SERVER['REQUEST_TIME']
)); 

I use the database driver with the following configuration

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'session'//my sesion table
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300

Does someone know what I am doing wrom?


RE: set_userdata doesn't realy set userdata - Nichiren - 02-23-2015

Your sessions table may need to be modified since the table schema for sessions changed in CI 3: http://www.codeigniter.com/userguide3/libraries/sessions.html#database-driver

MySql example:

Code:
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 DEFAULT '' NOT NULL,
       PRIMARY KEY (id),
       KEY `ci_sessions_timestamp` (`timestamp`)
);

Note that the `data` field is now a blob data type.


RE: set_userdata doesn't realy set userdata - bboom - 02-23-2015

My session table is exactly the same as the mysql example you gave. (I did that upgrade already).


RE: set_userdata doesn't realy set userdata - Narf - 02-23-2015

What does that description really mean? It's not saving to the database or ... ?

And how did you verify that? Did you look at the logs?


RE: set_userdata doesn't realy set userdata - bboom - 02-23-2015

I found what was wrong, I was trying to make a connection with the Joomla! CMS authentication, the Joomla! framework breaks the CodeIgniter session handler. When I comment the joomla imports it is working well.