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

Asked

Viewed 949 times

5

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 don’t understand is that "Mozilla /5.0" always appears (even if I use another browser, other than Firefox).

Example:

print_r($_SERVER['HTTP_USER_AGENT']);

Exit:

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

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

So here are two questions (I will be satisfied if only the first one is answered):

  • Why does this header return the browser name, it also returns "Mozilla /5.0"? It’s something else that has no relationship with Firefox?

3 answers

5

First you must understand the meaning user-agent, or the user’s agent, or whatever acts/interacts.

In general, it is necessary to know what kind of functionality is compatible with that agent, to then make the content available in an interpretable way to the same, and it is hence the confusion with the repeated Mozilla begins.

The first web browser, launched in 1993, was the Mosaic, and used it user-agent: NCSA_Mosaic/2.0.

To Mosaic Communications, responsible for the browser, became Netscape Communications, and created the Netscape Navigator, which was originally called Mozilla (a joke at the English junction of Mosaic and Killer - Killer of the Mosaic), and therefore his user-agent era Mozilla/1.0.

Like the browser of Netscape inserted interpretations for new functionalities, such as frames, the web servers began to provide pages with the new features, but needed to maintain compatibility with the old Mosaic, so they restricted the new pages to the agents they contained Mozilla, sending the old page, compatible with the Mosaic, to those who had not.

When the Microsoft created the Internet Explorer, launched in 1995, this had support for frames and other functionalities of Netscape, but your user-agent did not contain Mozilla, which caused the servers to return poor content, interpreting it as Mosaic. 8

Impatient to wait for the administrators became aware of their new navigator, who appropriated the name, and started sending the user-agent Mozilla/1.22, declaring itself compatible with the agent Mozilla. 10

Thus, user agent has the function of specifying compatibilities, and is used in this way until today, saying that it is compatible with Mozilla, or with KHTML like Gecko to show support for Gecko, and browsers Android posing as Safari. 14 15

Note that this is unrelated to the non-profit organisation Mozilla, responsible for Firefox.

5

That excellent article on the history of browsers explains a little about their history, and the section below is what matters most to 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 used its code, and they called themselves Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.2) Gecko/20040825 Camino/0.8.1 the one, and Mozilla/5.0 (Windows; U; Windows NT 5.1; de; 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 today - why the string user-agent starts with Mozilla/5.0.

  • 2

    This answer is wrong. IE does not use Gecko and has this string as user-agent. The same goes for Chrome, Opera and Safari, just to stay in the main ones.

  • So why does this show up @bigown?

  • @Wallacemaxters is in my answer

4


I don’t know how to answer in detail. I’m answering only to have an answer that’s not wrong.

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

Bad or lazy or malicious programmers use the string Mozilla to do certain checks on your codes and know if you can perform anything. If it used its own name, a lot of existing code that could run normally would not work for a if misplaced.

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

In fact the thing is worse because they like to put in several words to pass by several browsers.

  • Here at IT we have a catchphrase for this: My, what a gambit!

  • Probably something right in the programmers' line "bad or lazy ..." and of "... if misplaced" makes the Estadão photo widget not work in Opera :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.