I'm not exactly sure what the problem is but the cookies aren't available for subdomains. Is there any way around this, or is there a better way to set the cookies domain? Thanks!

Code:
<?php 
ini_set("session.cookie_domain", ".example.com"); 

// Set cookie and redirect when user change city 
if( isset($_POST['city']) && $_POST['city'] != '' ){ 
    $cookie_expire = time() + 50400;  
    setcookie('city', $_POST['city'], $cookie_expire, '/'); 

    header("Location: http://".$_POST["city"].".example.com"); 
    die(); 
} 

// Redirect if user selected default city 
if (isset($_COOKIE["city"])) { 
    $subdomain = array_shift(explode(".",$_SERVER['HTTP_HOST'])); 

    if ($_COOKIE["city"] != $subdomain) { 
        header("Location: http://".$_COOKIE["city"].".example.com"); 
        die(); 
    } 
}