When sending a HTTP request, IE sends the User-Agent variable to the server. A possible value (as seen by the network debugger):
User-Agent: Mozilla /5.0 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)
My question: How does IE (or any other browser) find out this variable? I'm asking this because when visiting some websites, this variable is different than others and I'd like to trace where the change is coming from. 'Compatibility settings' is one option, but I think there is more to it.
Can anyone explain the process of this variable?
The User-Agent appears in an HTTP Request Header, not an HTTP Response one. In general, the request is sent from browser to the web application. So the user-agent variable is filled by the browser. Different browsers will fill up this field with different values.
About how IE find those variables, I think you are asking about User-Agent Registry Keys.
You can also override certain tokens of the user-agent string by adding values to the following registry key.
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Windows
CurrentVersion
Internet Settings
5.0
User Agent
(default) = "Mozilla/4.0"
Compatible = "compatible"
Platform = "Windows NT 5.1"
Version = "MSIE 6.0"
Pre Platform
Token = Value
Post Platform
Token = Value
The default value of the User Agent key replaces the application name and application version tokens reported in the user-agent string. Be aware that the first seven characters are used for the application name, and the remaining characters specify the application version token.
The Compatible, Platform, and Version values replace the corresponding tokens in the user-agent string.
Additional tokens can be added to the user-agent string by using the Registry Editor to create new string values under the Pre-Platform key or Post-Platform key. The value name should be the complete token; the value data is ignored. Tokens added to the Pre-Platform key appear before the platform token in the final user-agent string. Tokens added to the Post-Platform key appear after the platform token in the final user-agent string. Multiple tokens in either the Pre-Platform key or Post-Platform key are displayed in an unpredictable order.