I have a PHP script that stores a url from which a form was submitted in a session variable and then compares it to the current page url. If it's not the same as the one stored in the session it gets unset, at least that's how it should work. The problem is that the if statement used for checking if the two urls match seeems to be ignored and the session vars get unset anyway.
$compare_url_old = array_shift(explode(',', $_SESSION['search_page']));
$compare_url_new = array_shift(explode(',', $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
if ($compare_url_new != $compare_url_old)
{
unset($_SESSION['search_page']);
unset($_SESSION['search_price_min']);
unset($_SESSION['search_price_max']);
unset($_SESSION['search_name']);
}
The strange part is that if I try to echo something within the if statement it works properly but for some reason the unset functions get called every time despite the result.