function detectiPhone($query){
$container = $_SERVER['HTTP_USER_AGENT'];
//print_r($container); //this prints out the user agent array. uncomment to see it shown on page.
$useragents = array ("iPhone","iPod");
if ($_GET['iphonechoice'] == 'no') {setcookie("iphoneTemplate", "noway", time() + 1814400);}
$this->iphone = false;
foreach ( $useragents as $useragent ) {
if (eregi($useragent,$container) && $_COOKIE['iphoneTemplate'] != 'noway') {
$this->iphone = true;
setcookie("iphoneTemplate", "yes", time() + 1814400);
}
if (eregi($useragent,$container) && $_COOKIE['iphoneTemplate'] == 'yes') {
$this->iphone = true;
}
}
In the code above the cookie gets set to 'yes' but it never gets set to 'noway'. Although I have used a bunch of echo statements to find that it is entering the iphonechoice IF statement but it does not set the cookie to 'noway'. Am I missing something?