[eluser]Unknown[/eluser]
I'm hoping someone will be able to help me with this. I've been getting into CI and I'm trying to use it on a new site I'm working on. Mostly things are going ok (very well in fact), but I've hit a problem with sessions. With traditional php I store a shopping cart in this way:
Code:
$_SESSION['shopcart'][$productid] = $productqty;
Or something like that. It gives something like:
Code:
$_SESSION['shopcart'][9483] = 4;
$_SESSION['shopcart'][3898] = 20;
$_SESSION['shopcart'][2334] = 1;
So I build up a session array that I can easily run through using a foreach:
Code:
foreach ($_SESSION['shopcart'] as $key => $value)
.... etc
I'm not sure how to get this working with CI, every time I tried (and I did try different approaches) I ended up with only one key/value combination in the array, it just overwrote it every time. So the first time through the loop I would end up with:
Code:
$_SESSION['shopcart'][9483] = 4;
But the second time through I would end up with:
Code:
$_SESSION['shopcart'][3898] = 20;
CI sessions would not keep the original session value.
I'm sure there must be a way to do this, any suggestions would be welcome.
Thanks in advance...