title: Codeigniter session regenerated after browser close
body: <p>I have a situation where by I need to store information into codeigniters session -> be able to close the browser window -> then open up the browser window and for it to recover all the items I stored in a session. I'm aware codeigniter doesn't actually use sessions and instead cookies so this should be really easy.... but it's not.</p>
  
  <p>In FF / Safari / Chrome this works fine but in IE 9 when I close and then re-open the window it regenerates the session id and doesn't pull back the data.</p>
  
  <p>For example this simple code:</p>
  
  <pre><code>$this-&gt;CI-&gt;session-&gt;set_userdata('username','My Username');
  echo $this-&gt;CI-&gt;session-&gt;userdata('username');
  </code></pre>
  
  <p>when run the first time outputs as expected. I then comment out line 1 and refresh the screen and the session data is again displayed correctely.</p>
  
  <p>Now I close the browser window and open it back up to the same page, again with line 1 commented out. It can't find the session data and the session id is now changed.</p>
  
  <p>I have sessions saving to the database in codeigiter and my session config looks like:</p>
  
  <pre><code>$config['sess_cookie_name']     = 'bcsession';
  $config['sess_expiration']      = 0;
  $config['sess_expire_on_close'] = FALSE;
  $config['sess_encrypt_cookie']  = TRUE;
  $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']  = 300;
  </code></pre>