Welcome Guest, Not a member yet? Register   Sign In
[CI2]Problem with session mechanism (solved)
#1

[eluser]Unknown[/eluser]
[edit2]
I Found the solution, it was just a little bug in my code. Sorry for the inconvenience ^ ^
[/edit2]

Hi everyone! ^^

I've got a strange problem with the CI2 session mechanism. The mechanism don't want to write data into the database. The session cookie works fine and i can write & read data using set_userdata() and userdata() but nothing is writed in the database.

Here is my config file :

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

And the session table schemas :

Code:
CREATE TABLE IF NOT EXISTS `sessions` (
  `session_id` varchar(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '0',
  `ip_address` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
  `user_agent` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `last_activity` int(10) NOT NULL DEFAULT '0',
  `user_data` text COLLATE utf8_unicode_ci NOT NULL,
  KEY `session_id` (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Has anyone already encountered this problem?
Do you have an idea for a solution?
Is this a bug?

[edit]
This does not work:
Code:
class MY_Controller extends CI_Controller {
  public function __construct() {
    parent::__construct();
  }
}

class Test extends MY_Controller {
  public function __construct() {
    parent::__construct();
  }

  public function index() {
    $this->session->set_userdata('propName','propVal');
    print_r($this->session->userdata('propName'));
    die();
    [b]// -> the session data ARE NOT STORED in the database[/b]
  }

}

What works:

Code:
class Test extends CI_Controller {
  public function __construct() {
    parent::__construct();
  }

  public function index() {
    $this->session->set_userdata('propName','propVal');
    print_r($this->session->userdata('propName'));
    die();
    [b]// -> the session data ARE STORED in the database[/b]
  }
}

Why ?????

[/edit]




Theme © iAndrew 2016 - Forum software by © MyBB