Mobile phone that use OperaMinisometimes don’t sent user agent header to the server. Instead, they send:

Opera/9.60 (J2ME/MIDP; Opera Mini/4.1.13068/488; U; en) Presto/2.2.0

This can cause a problem for web application that rely on user-agent detection, such as application that use WURFL So, after about an hour or two trying to debug the problem, I found some way to retrieve the original user-agent (device user-agent) instead of operamini user-agent.

The solution is to check for the existence of X-OperaMini-Phone-UA header. In PHP, it can be as simple as:


$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ( stristr( $user_agent, 'Opera Mini' ) ) {
  //its opera mini, try the X-OperaMini-Phone-UA
  $user_agent = isset( $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] ) ? $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'] : $user_agent;
}

//do your rest of the stuff here

So, now phone detection using user_agent will work as normal, even if the user use Opera Mini browser.