How can I delete session?
I would use this structure:

$_SESSION['mybasket'][$id] = [
  'label' =&gt; $label,
  'code' =&gt; $code,
  'price =&gt; $price,
];


Then you can delete one item

unset($_SESSION['mybasket'][$id]);


or the complete basket

unset($_SESSION['mybasket']);


You don't need the variable loop, to count the items use

$count = count($_SESSION['mybasket']);