PHP: Removing items from a session

evill_z

New Member
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:\[code\]<?phpsession_start();$removeditem = $_GET['item']; // this identifies the item to be removedunset($_SESSION['stuff'][$removeditem]); // "stuff" is the existing array in the session?>\[/code\]Here are what print_r gives for the following (using "7" as the example of the removed item):\[code\]$removeditem: 7$_SESSION['stuff'] (before and after removal)Array( [0] => 7 [1] => 24 [2] => 36)\[/code\]Am I missing something obvious?
 
Back
Top