title: CodeIgniter: Cart content gets lost after redirect
body: <p>I am trying to develop a small web shop with CodeIgniter. To store the items, I use the <a href="http://ellislab.com/codeigniter/user-guide/libraries/cart.html" rel="nofollow">Cart</a> library. Most of the time, everything works great. However, sometimes the content of the cart gets lost after a redirect.</p>
  
  <p>I found a couple of fixes on the web, but none of them works in my case. Here is my setup:</p>
  
  <ul>
  <li>I use the DB for storing sessions</li>
  <li>I don't use AJAX</li>
  <li>There is no underscore in the name of the session cookie</li>
  </ul>
  
  <p>Here is an example of a refresh:</p>
  
  <pre><code>public function add_item() {
      $item_id = $this-&gt;input-&gt;post('item');
  
      // Query database
      $item = $this-&gt;model-&gt;find_item($item_id);
  
      // Rewrite model info
      ...
  
      $data = array(
          'id'      =&gt; 'item-' . $item['id'] . '-size-' . $item['sizes'][$i]['id'],
          'qty'     =&gt; $qty,
          'price'   =&gt; $item['sizes'][$i]['price'],
          'name'    =&gt; $item['name'],
          'options' =&gt; array('short_name' =&gt; $item['short_name'])
      );
  
      $this-&gt;cart-&gt;insert($data);
  
      usleep(10000);
      redirect('shop');
  }
  </code></pre>