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