http user agent, doubt??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

http user agent, doubt??

Post by saumya »

Code: Select all

$useragent = $_SERVER ['HTTP_USER_AGENT'];
echo "<br><b>Your User Agent is</b>: " . $useragent;
hi,
The above code shows me the same user agent in both ie and firefox,why??!!
Let me show you the results

ie6:
Your User Agent is: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

Firefox:
Your User Agent is: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

though the version numbers are different but why its "Mozilla" always.

thanking you
saumya
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

You missed out on the Browser war between Internet Explorer and Netscape... Lots of features on the net in the 90's were compatible with either Netscape only or IE only. So a lot of code (js) used the user-agent string to disable features for incompatible browsers.

As IE gained dominance and other browsers emerged they needed to outwit these limitations and so they started to "pretend" to be something else. Hence IE5+ have Mozilla 2.0-4.0 in the user agent string. It's a false ID basically to fool disabling code.

Reminds of that horror Hotmail did a while back in creating a full page warning about using Opera or Mozilla... :evil: . Some browsers actually support the ability for the user to change their user-agent string as a preference. :)
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

OHH MY GOODNESS!!!!!!!!!!
thank you so much.
So we can say, ie is faking itself to be mozilla core!!??
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Pretty much...;) Not sure if IE7 still carried the Mozilla4.0 compatible string or something updated. Probably still the same string I guess.
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

simply microsoft.
they can not make there own.I am confident that they will be go with the same.Lets see.
thank you so much.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Well, you can't trust the user agent at all anymore. Some of the newer browsers allow you to change the user agent to anything. And you could go through some proxies that change the user agent.

With Opera you can spoof the user agent so you can look like any web browser out there.
Post Reply