What’s the best / simplest / most accurate way to detect the browser of a user?
Ease of extendability and implementation is a plus.
The less technologies used, the better.
The solution can be server side, client side, or both. The results should eventually end up at the server, though.
The solution can be framework agnostic.
The solution will only be used for reporting purposes.
On the server you’re pretty much limited to the UserAgent string the browser provides (which is fraught with problems, have a read about the UserAgent string’s history).
On the client (ie in Javascript), you have more options. But the best option is to not actually worry about working out which browser it is. Simply check to make sure whatever feature you want to use actually exists.
For example, you might want to use setCapture, which only MSIE provides:
Rather than working out what the browser is, and then inferring its capabilities, we’re simply seeing if it supports something before using it – who knows what browsers will support what in the future, do you really want to have to go back and update your scripts if Safari decides to support setCapture?