title: CI 2.0.3 session heisenbug: session is lost after some time 20 minutes, only on server redirect, nothing suspicious in the logs
body: <p>I can't seem to make any progress with this one. My CI session settings are these:</p>
  
  <pre><code>$config['sess_cookie_name']     = 'ci_session';
  $config['sess_expiration']      = 0;
  $config['sess_expire_on_close'] = FALSE;
  $config['sess_encrypt_cookie']  = FALSE;
  $config['sess_use_database']    = TRUE;
  $config['sess_table_name']      = 'ci_sessions';
  $config['sess_match_ip']        = FALSE;
  $config['sess_match_useragent'] = FALSE;
  $config['sess_time_to_update']  = 7200;
  $config['cookie_prefix']    = "";
  $config['cookie_domain']    = "";
  $config['cookie_path']      = "/";
  $config['cookie_secure']    = FALSE;
  </code></pre>
  
  <p>The session library is loaded on autoload. I've commented the sess_update function to prevent an AJAX bug that I've found about reading the CI forum. </p>
  
  <p>The <code>ci_sessions</code> table in the database has collation <code>utf8_general_ci</code> (there was a bug that lost the session after every <code>redirect()</code> call and it was linked to the fact that the collation was <code>latin1_swedish_ci</code> by default).</p>
  
  <p>It always breaks after a user of my admin section tries to add a long article and clicks the save button. The save action looks like this:</p>
  
  <pre><code>function save($id = 0){
      if($this-&gt;my_model-&gt;save_article($id)){
          $this-&gt;session-&gt;set_flashdata('message', 'success!');
          redirect('admin/article_listing');
      }else{
          $this-&gt;session-&gt;set_flashdata('message', 'errors encountered');
          redirect('admin/article_add');
      }
  }
  </code></pre>
  
  <p>If you spend more than 20minutes and click save, the article will be added but on redirect the user will be logged out.</p>
  
  <p>I've also enabled logging and sometimes when the error occurs i get the message <code>The session cookie data did not match what was expected. This could be a possible hacking attempt.</code> but only half of the time. The other half I get nothing: a message that I've placed at the end of the Session constructor is displayed and nothing else. In all the cases if I look at the cookie stored in my browser, after the error the cookie's first part doesn't match the hash.</p>
  
  <p>Also, although I know Codeigniter doesn't use native sessions, I've set <code>session.gc_maxlifetime</code> to 86400.</p>
  
  <p>Another thing to mention is that I'm unable to reproduce the error on my computer but on all the other computers I've tested this bug appears by the same pattern as mentioned above.</p>
  
  <p>If you have any ideas on what to do next, I'd greatly appreciate them. Changing to a new version or using a native session class (the old one was for CI 1.7, will it still work?) are also options I'm willing to consider.</p>
  
  <p><strong>Edit</strong> : I've run a diff between the Session class in CI 2.0.3 and the latest CI Session class and they're the same.</p>