The script below works on my dev box but not on the production box. I can't figure out why. The add portion works, it's the delete part that doesn't. For some reason it doesn't seem to unset the key. But it's weird, it will work on some, but not others. It's, if anything, an interesting problem.
<?
//Get the action and add or delete the item from the stored favorites.
if(isset($_GET['action'])){
$action = $_GET['action'];
if($action == "add"){
$returnurl = $_GET['returnurl'];
$propertyCode = $_GET['propertyCode'];
$_SESSION['favorites'][] = $propertyCode;
header("Location: $returnurl");
}elseif($action == "delete"){
$propertyCode = $_GET['propertyCode'];
if(in_array($propertyCode, $_SESSION['favorites'])){
$key = array_search($propertyCode, $_SESSION['favorites']);
unset($_SESSION['favorites'][$key]);
header("Location: favorites.php");
}else{
echo "Could not find Favorite in List<br />";
print_r($_SESSION['favorites']);
}
}
}
?>
What happens is that the keys it can't find, which are obviously in there because I output the array if it can't find the key, do exist but for some reason, the script won't find them to delete them.