Questions tagged [user-agent]

A user agent is a piece of software (a software agent) that acts on behalf of a user. The term is often used to refer to browsers, and other software that sends network requests. In the HTTP protocol, a user agent identifies itself to the server using a user-agent string. The user-agent string is a string in the header of an HTTP request that identifies the browser, version, device, os, and other information about the device from which the request came.

A user agent is a piece of software (a software agent) that acts on behalf of a user. The term is often used to refer to browsers, and other software that sends network requests. In the HTTP protocol, a user agent identifies itself to the server using a user-agent string. The user-agent string is a string in the header of an HTTP request that identifies the browser, version, device, os, and other information about the device from which the request came.

The user-agent usually consists of the web browser type, the client operating system and device identifier (all with versions or builds). There is not particular standard in how to formulate an user-agent, but browser and device vendors typically standardize within their own scope.

Detection User-agent detection can be hard, especially in the mobile world. Identification of client capabilities usually cannot be done via the user-agent, but must be obtained by looking up the user-agent in a database. The defacto standard user-agent for a device is the one created by its web browser.

2389 questions
708
votes
27 answers

Determine a user's timezone

Is there a standard way for a web server to be able to determine a user's timezone within a web page? Perhaps from an HTTP header or part of the user-agent string?
Kevin Dente
  • 25,430
  • 7
  • 43
  • 47
294
votes
16 answers

Auto detect mobile browser (via user-agent?)

How can I detect if a user is viewing my web site from a mobile web browser so that I can then auto detect and display the appropriate version of my web site?
TeddyTom
288
votes
13 answers

What is the purpose of the implicit grant authorization type in OAuth 2?

I don't know if I just have some kind of blind spot or what, but I've read the OAuth 2 spec many times over and perused the mailing list archives, and I have yet to find a good explanation of why the Implicit Grant flow for obtaining access tokens…
Dan Taflin
  • 2,883
  • 3
  • 14
  • 5
283
votes
18 answers

How to find the operating system details using JavaScript?

How can I find the OS name and OS version using JavaScript?
vipin katiyar
  • 3,437
  • 7
  • 24
  • 32
279
votes
6 answers

Why do all browsers' user agents start with "Mozilla/"?

All popular browsers' user agent strings, even Internet Explorer's, start with Mozilla/. Why is this the case?
sashaeve
  • 9,387
  • 10
  • 48
  • 61
253
votes
37 answers

Detect IE version (prior to v9) in JavaScript

I want to bounce users of our web site to an error page if they're using a version of Internet Explorer prior to v9. It's just not worth our time and money to support IE pre-v9. Users of all other non-IE browsers are fine and shouldn't be bounced.…
Chad Decker
  • 5,997
  • 8
  • 27
  • 31
220
votes
11 answers

How big can a user agent string get?

If you were going to store a user agent in a database, how large would you accomdate for? I found this technet article which recommends keeping UA under 200. It doesn't look like this is defined in the HTTP specification at least not that I found.…
JoshBerke
  • 66,142
  • 25
  • 126
  • 164
185
votes
9 answers

How to use Python requests to fake a browser visit a.k.a and generate User Agent?

I want to get the content from this website. If I use a browser like Firefox or Chrome I could get the real website page I want, but if I use the Python requests package (or wget command) to get it, it returns a totally different HTML page. I…
user1726366
  • 2,256
  • 4
  • 15
  • 17
169
votes
1 answer

Why do Chrome and IE put "Mozilla 5.0" in the User-Agent they send to the server?

When I myself send many requests to the server I found it amazing that in IE if I choose opera user string that the value of user string was User-Agent Opera/9.80 (Windows NT 6.1; U; en) Presto/2.2.15 Version/10.00 But if I choose another browser…
user605334
120
votes
3 answers

How to use curl to get a GET request exactly same as using Chrome?

I have a web api http://something.com/api and I want to use GET to get the response body. This is my command: curl "http://something.com/api" Of course, it fails and gives an error message. When I use Chrome and input the above url, everythings…
wdetac
  • 2,712
  • 3
  • 20
  • 42
120
votes
15 answers

What is the iPad user agent?

From what I gather, the iPad is using iPhone OS, but with a different screen resolution from the iPhone and iPod touch. So many sites may have to change their user agent detection to adapt to the iPad. So, can anyone with access to the iPad or the…
Yoric
  • 3,348
  • 3
  • 19
  • 26
111
votes
8 answers

Get operating system info

I recently started wondering about sites like http://thismachine.info/ that get the user's operating system info. I have not been able to find out how to do that with PHP, and wanted to try to figure it out. I noticed that they list the user-agent,…
pattyd
  • 5,927
  • 11
  • 38
  • 57
106
votes
5 answers

How to get user agent in PHP

I'm using this JS code to know what browser is user using for. And I want to get this navigator.appName to php code to use it like this: if ($appName == "Internet Explorer") { //…
Olga Budnik
  • 1,143
  • 2
  • 8
  • 10
101
votes
9 answers

Changing user agent on urllib2.urlopen

How can I download a webpage with a user agent other than the default one on urllib2.urlopen? urllib2.urlopen is not available in Python 3.x; the 3.x equivalent is urllib.request.urlopen. See Changing User Agent in Python 3 for…
das
100
votes
2 answers

Getting the User Agent with JavaScript

I'd like to get a script that can grab the user's user agent and prop it to an attribute. I'm making a website problems contact form and I usually need to know what browser the user is using. How can I detect the user agent string and prop it as the…
henryaaron
  • 6,042
  • 20
  • 61
  • 80
1
2 3
99 100