The User-Agent
Header -- Identify a User Agent and Client Device

The
User-Agent header contains a
line of text that can be used to identify a user agent and client
device.Most of the time, we
can find the device model and manufacturer from the User-Agent
header. It may also contain information such as the client
device's OS version, browser version, Java capabilities, etc.

One
big problem of the User-Agent
header is that its format is different for different
manufacturers of mobile devices / cell phones. There are also
variations among mobile devices / cell phones of the same
manufacturer. Future device models might include a new string token
in the User-Agent header or
even use a completely new User-Agent
header format.

Because
of such problems, even though the User-Agent
header may contain information about a mobile device's OS version,
browser version, Java capabilities, etc, usually we do not use
it for device capability detection. To detect the features and
capabilities of a mobile device, the UAProf way is preferred, which
will be discussed later in this tutorial.

In
general, the User-Agent
header is useful in the following situations:

When
we need to identify a specific mobile device model. For example, the
User-Agent header can
help us determine whether a mobile device is a Nokia 6230i cell
phone.

When
we need to differentiate mobile devices or user agents made by
different companies. For example, the User-Agent
header can help us determine whether a cell phone is made by Nokia
or Sony Ericsson.

When
we need to determine whether a user agent is a web browser on a
personal computer or a microbrowser on a mobile device.

To Identify a
Specific Mobile Device Model with the User-Agent Header

In
general, to identify a specific mobile device model, check whether
the mobile device model name appears in the User-Agent
header. For example, if the text "Nokia6230i" exists
in the User-Agent header, we
know that the mobile device is a Nokia 6230i cell phone; if the text
"SonyEricssonK700i" exists in the User-Agent
header, we know that the mobile device is a Sony Ericsson K700i cell
phone.

As
said earlier, each mobile device manufacturer has its own User-Agent
header format. Thus, the keyword to use to identify a specific mobile
device model is different for different manufacturers. You may need
to check the website of the mobile device manufacturer to find its
User-Agent header
format or consider to use other detection methods such as
UAProf. (With UAProf, the mobile device model and manufacturer name
are available in the Model
attribute and the Vendor
attribute of the HardwarePlatform
component respectively.)

To Differentiate
Mobile Devices or User Agents Made by Different Companies with the
User-Agent Header

In
general, the User-Agent
header contains information that can help us differentiate mobile
devices or user agents made by different companies. Here are some
examples: (Note: the keywords below are in lowercase but they
may not be so in the actual User-Agent
header)

The
word "nokia" can be found in the User-Agent
header of Nokia's cell phones.

The
word "motorola" or "mot-" can be found in the
User-Agent header of
Motorola's cell phones.

The
word "samsung" or "sec-" can be found in
the User-Agent header of
Samsung's cell phones.

The
word "lg-" can be found in the User-Agent
header of LG's cell phones.

The
word "sonyericsson" can be found in the User-Agent
header of Sony Ericsson's cell phones.

The
word "sie-" can be found in the User-Agent
header of Siemens' cell phones.

The
word "up.b" or "up/" can be found in the
User-Agent header of
cell phones that uses the Openwave Mobile Browser. The
Openwave Mobile Browser can be found in many cell phone models made
by a variety of manufacturers such as Motorola, Samsung, LG,
Siemens, etc.

Note
that UAProf is a more elegant way for differentiating the
manufacturers of mobile devices / user agents. (With UAProf, the name
of the manufacturer is available in the
Vendor attribute of
the HardwarePlatform
component.)

To
Determine Whether a User Agent is a Web Browser on a Personal
Computer or a Microbrowser on a Mobile Device with the
User-Agent Header

Another
common use of the User-Agent
header is to determine whether the user agent is a web browser on a
personal computer or a microbrowser on a mobile device. Below shows
the User-Agent header
of Microsoft Internet Explorer 6 and Mozilla Firefox 1.0.7 running on
Windows 2000:

If
you compare the User-Agent
headers of IE and Firefox with those of microbrowsers that were shown
earlier, you will find that the User-Agent
header of IE and Firefox contains the word "Mozilla" while
those of microbrowsers do not. This can be served as a simple
rule to determine whether a user agent is a web browser on a personal
computer or a microbrowser on a mobile device.

Note
that the above rule does not work in all cases. The User-Agent
header of some microbrowsers also contains the word "Mozilla".
For example, some Nokia 6630 cell phones use a "Mozilla
compatible" User-Agent
header. The reason is that Nokia
6630 is a web-compatible cell phone and can accept HTML
content, butsome websites
that are designed for desktops will deny access to Nokia 6630 if the "Mozilla
compatible" User-Agent
header is not present.

To
increase accuracy, you can further check the OS name and browser name
in the User-Agent header.
For example, if you find the word "Mozilla" and the OS name
"Windows NT" in the User-Agent
string, it is almost certain that the user agent is a web browser on
a computer but not on a mobile device; if you find the word "Mozilla"
and the browser name "Firefox", it is certain that
the user agent is a Firefox browser running on a computer since
Firefox does not have a mobile device version (at the time of this
writing).

What do you think about this web page? It is very helpful. It is helpful, but some information I wanted is missing. It is not helpful. It has broken links. It has typos / grammatical mistakes. It has incorrect information. Others

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Due to the amount of messages we received, we may not be able to reply to all messages.