I'm currently getting my cart sorted on my online store. I have the cart set as an array which is a session variable. I can get items added to the cart easy enough but I'm having trouble removing them. I've tried removing them using unset on the session variable or getting the session variable, updating it as a local variable and then setting the updated version as the session variable yet none of them have worked.
The value $_SESSION["cart"] is an array with items that are in the cart. $_GET["account"] is the index of the item they want to remove from the cart. Here is my current code:
if (isset($_GET["account"])) {
$accountnumber = $_GET["account"];
$cart = $_SESSION["cart"];
unset($cart[$accountnumber]);
$_SESSION["cart"] = $cart;
}
Please let me know what's wrong with it.
Thanks