wintallo Posted September 4, 2006 Share Posted September 4, 2006 Hey, I was wondering if anyone knew of a script that checked a user's browser user agent and either let them onto a page, or didn't let them onto a page. I mean, say I required a user to have the user agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6How would I make it so only people with this user agent could access a page. If you have no idea what i'm talking about, I want something that works like this website. (except not for PSP)http://www.geneonanimation.com/psp/Thanks!Joelwintallo.com Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 [code]$ua = $_SERVER['HTTP_USER_AGENT'];if ($ua != "some very long string") { die("You can't access this page as you have the wrong user agent");}[/code] Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 4, 2006 Share Posted September 4, 2006 reliance on the user agent string is not bullet proof, because it is of course dependant on the user agent broadcasting it in the first place.FireFox allows the user to change their user agent string quite easily for example.In other words.. make your site accessible to all browsers.Should also use a keyword search rather than standard comparison:[code]<?phpif (stripos('mozilla', $_SERVER['HTTP_USER_AGENT']) === false) { die('Get firefox.');}?>[/code] Quote Link to comment 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.