prova a stampare l'array $_SESSION.....

Codice PHP:
if (isset($_GET['buy'])) {
  
// Add item to the end of the $_SESSION['cart'] array
  
$IDaggiungi $_GET['buy'];
  
$_SESSION['cart'][$IDaggiungi]++;
  echo 
"<pre>";
  
print_r($_SESSION);

  
// header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
  
exit();

vedi un po' cosa valorizzi nel $_SESSION