title: Session empty codeigniter
body: <p>First, sorry for my english :D</p>
  
  <p>I try to make a simple login on Codeigniter without succes. I read the official documentation and reduce the script to minimum necessary. My session is empty every time i redirect o refresh my page or if i going to another controller. If i create only one controller and make simple read and write it is going well until i refresh or redirect.</p>
  
  <p>This is what I want to do:
  1) first controller is main controller. Load a view with a login form. This form has a action to method validation_form and then username_check callback.</p>
  
  <p>2) if the user was able to logged in, i set my userdata and redirect to restriced controller, that is my restricted area.</p>
  
  <p>P.S. i use library session in autoload with the option database active. I have database library in autoload too. </p>
  
  <p>MAIN CONTROLLER</p>
  
  <pre><code>class Main extends CI_Controller {
  
  
  public function __construct(){
      parent::__construct();
  
  }
  
  public function index()
  {
      $this-&gt;load-&gt;view('login_view');
  }
  
  public function validation_form()
  {
      $this-&gt;load-&gt;library('form_validation');
      $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'required|callback_username_check');
      if ($this-&gt;form_validation-&gt;run() == FALSE){
         echo 'validation_error';
      }else{
         redirect('/restricted');
      }
  }
  
  public function username_check(){
      $this-&gt;load-&gt;model('login_model');
      $email=$this-&gt;input-&gt;post('email');
      $login=$this-&gt;login_model-&gt;validate($email);
      if ($login != FALSE){                    
                  return true;
      }
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>LOGIN MODEL</p>
  
  <pre><code>class Login_model extends CI_Model{
  
  public function __construct(){
      parent::__construct();
  }
  
   public function validate($email){
  
      // Prep the query
      $this-&gt;db-&gt;where('EmailDatore', $email);
  
      // Run the query
      $query = $this-&gt;db-&gt;get('Datore');
      // Let's check if there are any results
      if($query-&gt;num_rows() == 1)
      {
          // If there is a user, then create session data
          $row = $query-&gt;row();
          $data = array(
                  'email' =&gt; $row-&gt;EmailDatore,
                  'nome' =&gt; $row-&gt;Nome,
                  'cognome' =&gt; $row-&gt;Cognome,                    
                  'validated' =&gt; true
                  );
          $this-&gt;session-&gt;set_userdata($data);
          return true;
      }
      // If the previous process did not validate
      // then return false.
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>RESTRICTED CONTROLLER
      class Restricted extends CI_Controller{</p>
  
  <pre><code> public function __construct(){
      parent::__construct();
      $this-&gt;check_isvalidated();
  }
  
  public function index(){
      // If the user is validated, then this function will run
      echo 'Congratulations, you are logged in.';
  }
  
  private function check_isvalidated(){
      if(! $this-&gt;session-&gt;userdata('validated')){
          redirect('main');
      }
  }
  </code></pre>
  
  <p>}</p>