I couldn't understand everything you were attempting from the question you asked, yet after sifting though your code, this is what I got.
You wanted a session containing products. If that product was found (a duplicate) then the quantity should be increased. However, to effectively organize it all, having multiple duplicate entries into the array would make sorting though it all a pain. So, I've revised the code to house a multidimensional array, that keeps track of each item added to the products session and a quantity count for each duplicate item.
session_start();
if(isset($_GET['id']))
{
$newProduct = array('item' => $_GET['id'], 'count' => 1);
if(isset($_SESSION['products']))
{
$found = false;
$currentProducts = $_SESSION['products'];
for($i = 0; $i < count($currentProducts); $i++)
{
foreach($currentProducts[$i] as $key => $value)
{
if($key == "item")
{
if($value == $_GET['id'])
{
$found = true;
$currentItem = $currentProducts[$i];
}
}
}
if($currentProducts[$i]["item"] == $_GET['id'])
$currentProducts[$i]["count"] = $currentProducts[$i]["count"] + 1;
}
if($found)
{
$_SESSION['products'] = $currentProducts;
}
else
{
$_SESSION['products'][] = $newProduct;
}
}
else
{
$_SESSION['products'] = array($newProduct);
}
echo "<pre>", print_r($_SESSION['products']), "</pre>";
}
It's not the cleanest way to do it, but it makes working with the session array a bit easier. Especially when you decide to display the items in a shopping cart fashion.
I hope this helps