Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect what browser is used to access my site?

Tags:

browser

http

How do I detect what browser (IE, Firefox, Opera) the user is accessing my site with? Examples in Javascript, PHP, ASP, Python, JSP, and any others you can think of would be helpful. Is there a language agnostic way to get this information?

like image 460
Bill the Lizard Avatar asked Nov 28 '22 21:11

Bill the Lizard


2 Answers

If it's for handling the request, look at the User-Agent header on the incoming request.

UPDATE: If it's for reporting, configure your web server to log the User-Agent in the access logs, then run a log analysis tool, e.g., AWStats.

UPDATE 2: FYI, it's usually (not always, usually) a bad idea to change the way you're handling a request based on the User-Agent.

like image 59
Hank Gay Avatar answered Dec 04 '22 12:12

Hank Gay


Comprehensive list of User Agent Strings from various Browsers

The list is really large :)

like image 42
prakash Avatar answered Dec 04 '22 11:12

prakash