title: Detecting smartphone/tablet browsers that support cookies and jQuery Mobile
body: <p>I have a website with a full browser and jQuery Mobile interface and users can switch between the two. Their preference is stored in a cookie. By default the site serves the full version to visitors whitout a preference cookie, but to make it better for modern smartphone users I want their default to be JQM. So, I have this code in the constructor of my base controller class:</p>
  
  <pre><code>class BaseController
  {
  
      protected $mobile;  // must be 0 or 1, cookies can't handle boolean 'false'
  
      public function __construct()
      {
          if (isset($_COOKIE['mobile']))
          {
              $this-&gt;mobile = $_COOKIE['mobile'];
          }
          else
          {
              $this-&gt;mobile = $this-&gt;isSmartphoneWithCookies();
              setcookie("mobile", $this-&gt;mobile, time() + 7776000, '/', ''); // 90 days
          }
      }
  
      private function isSmartphoneWithCookies()
      {
          $SMARTPHONE_WITH_COOKIES = "android.+mobile|blackberry|ip(hone|od)|opera m(ob|in)i";
  
          return preg_match("/$SMARTPHONE_WITH_COOKIES/i", $_SERVER['HTTP_USER_AGENT']) ? 1 : 0;
      }
  
      // the rest of my controller class....
  }
  </code></pre>
  
  <p>Here I prefer speed to accuracy, so I am not looking for a slower, up-to-date lookup service as suggested here: <a href="https://stackoverflow.com/questions/5122566/simple-smart-phone-detection">Simple Smart Phone detection</a></p>
  
  <p>Just a quick indication that the visitor has one of the current top smartphone/tablet browsers that support cookies and JQM.</p>
  
  <p>Can someone suggest an improvement for my $SMARTPHONE_WITH_COOKIES? Or point me to a collection of UA signatures that fit my use case? Specifically, is it safe to have blackberry in the list? Am I overlooking a popular capable browser?</p>