johnnyk Posted July 10, 2006 Share Posted July 10, 2006 How reliable is PHP's browser detection? I'm assuming it's set by the user agent, so is it ever wrong? Quote Link to comment https://forums.phpfreaks.com/topic/14138-browser-detection/ Share on other sites More sharing options...
willfitch Posted July 10, 2006 Share Posted July 10, 2006 It's as reliable as the headers being sent to the web server. $_SERVER['HTTP_USER_AGENT'] Quote Link to comment https://forums.phpfreaks.com/topic/14138-browser-detection/#findComment-55394 Share on other sites More sharing options...
johnnyk Posted July 10, 2006 Author Share Posted July 10, 2006 So what does that mean? php.net says $_SERVER['HTTP_REFERER'] isn't reliable because it can be modified by the user-agent. Can $_SERVER['HTTP_USER_AGENT'] be modified by the user agent? Quote Link to comment https://forums.phpfreaks.com/topic/14138-browser-detection/#findComment-55403 Share on other sites More sharing options...
Daniel0 Posted July 10, 2006 Share Posted July 10, 2006 [url=http://php.net/get_browser]get_browser[/url] is an option too.And yeah, HTTP_REFERER (and HTTP_USER_AGENT too) is [i]very[/i] easy to spoof, but there is no spoof-proof way of getting the user agent. It works in the way that the browser actually sends the information along with the request, and you can modify what it sends quite easily. Quote Link to comment https://forums.phpfreaks.com/topic/14138-browser-detection/#findComment-55408 Share on other sites More sharing options...
willfitch Posted July 10, 2006 Share Posted July 10, 2006 Like I said, it's as reliable as the browser sending the headers. When I wrote a C++ crawler, I sent a user agent header that corresponded with my crawler. It is very easy to spoof, but under what circumstances are you testing this other than javascript? Sometimes it can actually be better to detect within JavaScript, since JS would have been already downloaded. Even better, detect with both! Quote Link to comment https://forums.phpfreaks.com/topic/14138-browser-detection/#findComment-55661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.