title: Wrong user agent detection the first time entering the websie
body: <p>I have strange problem in my Wordpress site.<br>
  If someone enters the website from <strong>mobile</strong> device, the server serves the regular home page, than if the user refreshes the mobile site is loaded correctly.</p>
  
  <p>In the desktop PC it shows the regular site as usual.</p>
  
  <p>The way I load the mobile site is:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  /*
      Template Name: some_page
  */
  
  $iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
  $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
  $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
  $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
  $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
  
  if ($iphone || $android || $palmpre || $ipod || $berry){
      include_once('mobile_page.php');
      exit();
  }
  ?&gt;
  </code></pre>
  
  <p>any idea what could be possibly wrong?</p>