PDA

View Full Version : http referer variable


eugene
08-13-2003, 04:46 PM
I was told about an http referer variable that I could use to make sure a content page does not get viewed unless a link froma specific page is clicked but I have not been able to find such a code for php... does anyone here have a snippet or a link to where I can get this code in functional form. :confused:

Ökii
08-13-2003, 06:22 PM
$_SERVER['HTTP_REFERER'] will either yield the last page or nothing, dependent upon browser and proxy. Ergo it is not a secure test

anyway

$a = $_SERVER['HTTP_REFERER'];
if((strpos($a, 'www.abba.com') > -1) || ($a == ''))
{
// good referer
}

Spookster
08-13-2003, 06:28 PM
Note that http referer information is supplied by the browser and not all browsers supply that information or supply it correctly or it may be blocked by a proxy as Okii mentioned so in any case it is unreliable at best.

eugene
08-13-2003, 06:50 PM
DOESNT EVEN WORK FOR MY BROWSER...LOL
I may just rename the folder every so often since theres not much that can be done.

Spookster
08-13-2003, 06:57 PM
Originally posted by eugene
DOESNT EVEN WORK FOR MY BROWSER...LOL
I may just rename the folder every so often since theres not much that can be done.

Well there are always other ways of doing things. So basically you do not want a certain page viewed unless the person clicked on a link that exists in another specific page?

Is that other page also in your site? If so you could probably use a session variable to store a variable if they went to that other page and clicked the link.

Another way could be to use include files and make the restricted viewing page only available to your script and not available to the public. When the proper link is click then include the restricted viewing page.

eugene
08-13-2003, 07:39 PM
yes both pages are on my site hosted on my server here at home

you lost me on the last bit
can you give me an example as to what your talking about?
I know what the include part does but im not sure how to go about setting up sessions and all of that... can you help a php newbie out? ive only been into php about 3 months so far