CodeIgniter Forums

Full Version: CI 3.0 is losing Session always
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I have started a web site with CI 3.0, but I am with a problem with storing session.

I create the session example:

PHP Code:
$newdata = array(
 
       'username'  => 'johndoe',
 
       'email'     => 'johndoe@some-site.com',
 
       'logged_in' => TRUE
);

$this->session->set_userdata($newdata); 


But in refresh, every sessions has removed.

My config:

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300

My autoload

PHP Code:
$autoload['libraries'] = array('database''session');
$autoload['drivers'] = array('session'); 
You should remove session from the drivers autoload since it's a library. When you say it's removed, do you mean it's not in the DB or when you try to use $this->session->userdata( 'username' ) you don't get the expected value?
I removed the autoloaders.

But in a example, controller Login I create de session, and still I can't show the session using: $this->session->userdata( 'username' )
Did you create the table: "ci_session" in your database?
Depending on your DB drive, the file structure is different.

Lots of information in the 3.0 User Guide:

file:///home/twp/Dev/CI3.0/user_guide/libraries/sessions.html#database-driver

Check that your app configuration meets the three conditions stated at the top of section on the database session driver.  Second paragraph:

Quote:
  • Only your default database connection (or the one that you access as $this->db from your controllers) can be used.
  • You can NOT use a persistent connection.
  • You must have the Query Builder enabled.
Yes, i created the table and it is works!

That's ok now, was a problem with logout() in a librarie.

Thanks