Jump to content


[SOLVED] User Agent Reader

  • Please log in to reply
2 replies to this topic

#1 wintallo

  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts

Posted 04 September 2006 - 01:53 AM

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: Gecko/20060728 Firefox/

How 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)




#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 September 2006 - 05:21 AM

if ($ua != "some very long string") {
    die("You can't access this page as you have the wrong user agent");

Legend has it that reading the manual never killed anyone.
My site

#3 Jenk

  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 04 September 2006 - 09:26 AM

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:

if (stripos('mozilla', $_SERVER['HTTP_USER_AGENT']) === false) {
    die('Get firefox.');


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users