here is the code I am using
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;
}
}
basically it runs and sets the cookie to yes, but even when it enters the iphonechoice if statement it will not change the cookie to 'noway'. All of this is being done before the headers are printed... I just don't see why it sets it to 'yes' enters the if statement and never changes to 'noway'
I tracked it down with a bunch of echos and this is where I am stuck. Please let me know.