PHP Session problem. When item is added it adds 1 to all of the items

one text

Solution:

Based on the code you've posted, something like this should work. I've added some comments to explain the code.

<?php 

session_start();

// Initialise session to existing value or zero
$_SESSION['chaser'] = $_SESSION['chaser'] ?? 0;
$_SESSION['bmw'] = $_SESSION['bmw'] ?? 0;

// Determine selected car
$car = $_GET['id'] ?? null;

// Increment selected car
if ($car) {
    $_SESSION[$car] += 1;
}

header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/basket-session.php'); 

Source