Why does the User-Agent header always return "Mozilla /5.0" regardless of browser?

2

I know that in PHP we can access a header called User-Agent and thus discover information about the operating system and browser, used by the client.

The only thing I do not understand is that "Mozilla /5.0" always appears (even if I use a browser other than Firefox).

Example:

print_r($_SERVER['HTTP_USER_AGENT']);

Output:

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0

This string above was returned from PHP. I was using Firefox 39.0 in my tests. However, if I did this with another browser, I would return "Mozilla / 5.0"

So here are two questions (I'll be happy if only the first one is answered):

  • Why does this header return the browser name, also returns "Mozilla /5.0"? Is it something else that has no relationship with Firefox?
asked by anonymous 09.09.2015 / 13:57

2 answers

2

I do not know how to respond in detail. I am only responding to have an answer that is not wrong.

The reason browsers use this should be more or less the same as what they claim Windows 10 does not call Windows 9 .

Bad or lazy or malicious programmers use string Mozilla to do certain checks on their codes and see if they can do anything. If you used your own name, a bunch of existing code that could run normally would not run with a misplaced%.

Then all browsers pretend to be Mozilla to not be harmed by bad codes.

Actually the thing is worse because they like it by several words to get through several browsers.

    
10.09.2015 / 17:22
3

This excellent article on the history of browsers explains a little about their history, and the below is what most interests the context of the question:

  

(...) Mozilla built Gecko, and called itself Mozilla / 5.0 (Windows; U; Windows NT 5.0; en-US; rv: 1.1) Gecko / 20020826, and Gecko was the rendering engine, and Gecko was good . And Mozilla became Firefox, and called itself Mozilla / 5.0 (Windows; U; Windows NT 5.1; sv-SE; rv: 1.7.5) Gecko / 20041108 Firefox / 1.0, and Firefox was very good.

     

And Gecko began to multiply, and other browsers were born that they used their code, and they called themselves Mozilla / 5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; / 20040825 Path / 0.8.1 the one, and Mozilla / 5.0 (Windows; U; Windows NT 5.1; rv: 1.8.1.8) Gecko / 20071008 SeaMonkey / 1.0 another, each pretending to be Mozilla, and all of them powered by Gecko.

Basically, Gecko (which is also called Mozilla / 5.0) is the open-source rendering engine implemented by most browsers nowadays - so the user-agent string starts with Mozilla / 5.0.

    
09.09.2015 / 15:05