I'm having trouble removing items in a session array in a shopping cart project. The following code should take the selected item and remove it from the session. However the end result is just the same session as before with nothing removed. I've seen similar problems by googling, but haven't found a working solution yet. Here is the stripped down code:
<?php
session_start();
$removeditem = $_GET['item']; // this identifies the item to be removed
unset($_SESSION['stuff'][$removeditem]); // "stuff" is the existing array in the session
?>
Here are what print_r gives for the following (using "7" as the example of the removed item):
$removeditem:
7
$_SESSION['stuff'] (before and after removal)
Array
(
[0] => 7
[1] => 24
[2] => 36
)
Am I missing something obvious?