title: Session lost after redirect in Codeigniter
body: <p>I'm using codeigniter as a framework.</p>
  
  <p>Firstly, I use <code>localhost</code> but when I change to my IP address the login function doesn't work anymore. I found that the session is lost after redirect to another controller.</p>
  
  <p>Here is the result of <code>print_r($this-&gt;session-&gt;all_userdata());</code></p>
  
  <pre><code>[session_id] =&gt; 7b00fa0f8790f48d24446f9eb4e6aab2 
  [ip_address] =&gt; 10.42.68.71 
  [user_agent] =&gt; Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1
  [last_activity] =&gt; 1285962398 
  [user_data] =&gt;
  </code></pre>
  
  <p>As you can see it doesn't have any data passed to <code>user_data</code> but it was set before redirect when I test.</p>
  
  <p>I separate the controller to two which the first one is users -> handler of login function and another is planner which handler of the link that I redirect from users controller.</p>
  
  <p><code>users.php</code> (first controller):</p>
  
  <pre><code>$this-&gt;load-&gt;model('users_model');
  $this-&gt;load-&gt;model('mymodel');
  $this-&gt;load-&gt;database();
  
  $email = $this-&gt;input-&gt;post('email');
  
  $pass = $this-&gt;input-&gt;post('password');
  
  $type = $this-&gt;input-&gt;post('type');
  
  // Authenticate the user
  $userdata = $this-&gt;users_model-&gt;auth_user($email,$pass,$type);
  
  if($userdata)
  {
      $data = array('FIRSTNAME' =&gt; $userdata-&gt;FIRSTNAME, 
                    'LASTNAME' =&gt; $userdata-&gt;LASTNAME, 
                    'EMAIL' =&gt; $userdata-&gt;EMAIL,
                    'LOGIN' =&gt;TRUE, 'TYPE' =&gt; $type);
      $this-&gt;session-&gt;set_userdata($data);
      redirect('planner/view_system','refresh');
  }
  </code></pre>
  
  <p><code>planner.php</code> (second controller):</p>
  
  <pre><code>function __construct() {
      parent::__construct();
  
      if ( ! ($this-&gt;session-&gt;userdata('LOGIN')))
      { 
          print_r (var_dump($this-&gt;session-&gt;userdata('FIRSTNAME')));
          print_r($this-&gt;session-&gt;all_userdata());
      }
      $this-&gt;load-&gt;helper(array('form','html','url'));
  </code></pre>
  
  <p>And here is my config</p>
  
  <pre><code>$config['sess_cookie_name']     = 'ci_session';
  $config['sess_expiration']      = 7200;
  $config['sess_expire_on_close'] = FALSE;
  $config['sess_encrypt_cookie']  = FALSE;
  $config['sess_use_database']    = FALSE;
  $config['sess_table_name']      = 'ci_sessions';
  $config['sess_match_ip']        = TRUE;
  $config['sess_match_useragent'] = FALSE;
  $config['sess_time_to_update']  = 300;
  </code></pre>