Welcome Guest, Not a member yet? Register   Sign In
CI 3.0 is losing Session always

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'     => '[email protected]',
       'logged_in' => TRUE


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' )

(This post was last modified: 03-01-2015, 02:17 PM by twpmarketing.)

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:


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

  • 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.


Theme © iAndrew 2016 - Forum software by © MyBB