i have session variable associated with user the first time the following code without the second line is execute it works on second time it does not giving me undefined offset.
unset($_SESSION['cart_items'][$i]);
this line of code solve the problem but my head is not getting around it
$_SESSION["cart_items"] = array_values($_SESSION["cart_items"]);