0

Rather confused by this. I'm using Chrome and my $_SERVER['USER_AGENT'] is returning this;

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36

Since it has Mozilla, AppleWebKit, Chrome, and Safari all listed there, how do I know which browser is being used since a preg_match('/Chrome/', $agent) would always return true for Chrome?

Skittles
  • 2,866
  • 9
  • 31
  • 37
  • 3
    This is exactly why you shouldn't use User Agent to determine the browser - too many people used to use that to serve different versions of their websites depending on which browser you were using (in theory to detect whether it supported certain features) so now all browsers just list themselves as "compatible" with basically every other browser, making it nigh impossible to determine the actual browser. Not to mention you can just change it in the browser settings. – Niet the Dark Absol May 08 '19 at 15:33
  • Possible duplicate of [reliable user browser detection with php](https://stackoverflow.com/questions/2257597/reliable-user-browser-detection-with-php) –  May 08 '19 at 15:35
  • Not sure if this type of thing is allowed, but here's a good history of why the user agent string is such a mess, and should not be relied upon: https://webaim.org/blog/user-agent-string-history/ – Erebus May 08 '19 at 16:02

0 Answers0