Jump to content


This topic is now archived and is closed to further replies.


[SOLVED] User Agent Reader

Recommended Posts

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)




Share this post

Link to post
Share on other sites
[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");

Share this post

Link to post
Share on other sites
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.');


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.