So currently on my website I log users OS
when they register an account. And then they can view it (their OS
that was logged upon registration) on their "account page".
But my question is, is getting users OS
from parsing useragent
in PHP reliable? For example I get users useragent
via this $_SERVER['HTTP_USER_AGENT']
in php, then parse it to extract their OS
from the useragent
. Can I rely on this being accurate for legitimate users?
I don't really care if hackers can spoof the useragent
, all I really am wondering is if this ($_SERVER['HTTP_USER_AGENT']
) will give me the users accurate OS
from legitimate (non hacker) site visitors?
Yes its reliable for non hacker user.
More Explaination
The user agent string is a text that the browsers themselves send to the webserver to identify themselves, so that websites can send different content based on the browser or based on browser compatibility.
Mozilla is a browser rendering engine (the one at the core of Firefox) and the fact that Chrome and IE contain the string Mozilla/4 or /5 identifies them as being compatible with that rendering engine.
You can also use get_browser() function of php.