Can anyone tell me why I keep getting the else and alert is not being triggered at all? The cookie is being set just while the browser is open.
<?php
$setcookie = setcookie('version', 'nova');
$browser = get_browser(null, true);
if(!isset($setcookie)){
if($browser["MSIE"] < 8.0){
// display message or alert!
echo "<script language=\"JavaScript\">\n";
echo 'alert("Please upgrade to version 8.0+ in order to view this site.");';
echo "</script>";
}
}
else
{
echo "Browser is current:";
}
?>
Your
ifcondition is wrong. You want to check the$_COOKIEarray, not the return value ofsetcookie.