It's not like you need to store the $id as both the key and the value.
If IDs are unique, then
$_SESSION["cart"][$id] = $qty;
If you want to store more information
$_SESSION["cart"][$id] = array('quantity'=>$qty, 'somethingelse'=>$thing);
And if IDs are not unique then they count as "more information":
$_SESSION["cart"][] = array('id=>$id, 'quantity'=>$qty, 'somethingelse'=>$thing);
Where [] means that PHP will generate a key for you.