I have question about the SESSION array.
I just add item and qty in different session. I use code like this :
$_SESSION[\'idproduct\'] = $id.\",\";
Store them as arrays, that way you can access the quantity using the ID as a key:
$_SESSION['quantity'][$id] = $quantity;
So instead of storing your ID and Quantity in two separate strings, you have them in one array, with the ID as the key. Converting your example above your array will look like this:
array(
1 => 3
4 => 4
6 => 5
);
Then if you wanted to add / adjust anything you just set $id
and $quantity
to the appropriate values and use the line above.