Page 1 of 1
Server variable (Referer) doesn't work
Posted: Tue Jul 29, 2003 10:18 am
by Swede78
$HTTP_SERVER_VARS['HTTP_REFERER']
This variable just stopped working for me. It was working before, now it gives me nothing when I try to echo it. I don't think I've changed any settings between the time it worked and now, but I'm not 100% sure of that. Is there anything that would cause this to not work?
Or does anyone know of another way to detect the URL of the last page you came from?
Posted: Tue Jul 29, 2003 2:28 pm
by m3rajk
go to
http://www.php.net and checkthe version you're using. it was probably deprecated.
the $HTTP_XXXX_VARS arrays have all been deprecated. for $_XXXX
Posted: Tue Jul 29, 2003 2:48 pm
by Swede78
$_SERVER['HTTP_REFERER'] doesn't work either.
Posted: Tue Jul 29, 2003 2:53 pm
by m3rajk
have you tried searching what's there by default via
http://www.php.net? how about checking that your test is working rright.. ie: that your bastion host allows refferes to be sent
Posted: Tue Jul 29, 2003 3:06 pm
by nielsene
Well did you change browsers? The "User-Agent" aka browser is responsible for setting the HTTP_REFERER value. Normally its set when you click a link, so if you/a user reaches the page via a bookmark or via directly typing a url then no HTTP_REFERER will be set. Furthermore some proxies strip HTTP_REFERER information.
Are you testing from a different location than before so maybe there is a different proxy?
ps. the hard part about HTTP_RERERER is knowing when to stop ERERERERERER...

Posted: Thu Jul 31, 2003 9:35 am
by Swede78
Nielsene,
That's what it was. I was going to the test URL directly. That makes sense. It was working before and is still working. Some people are getting to the page directly and some people are getting there through a link within my site. Sorry to waste your time.
Thanks,
Swede
Posted: Thu Jul 31, 2003 9:49 am
by m3rajk
no problem swede. everyone spaces out at times. it may have been good for you to have spaced out here so that you found out about the deprecation
Posted: Sat Aug 02, 2003 11:29 pm
by jmarcv
nielsene:
>The "User-Agent" aka browser is responsible for setting the HTTP_REFERER value.
Really??? I thought that came from Apache, since it is an apache enviornment variable!
God help us when we have to depend on browsers for data!
Posted: Sun Aug 03, 2003 7:51 am
by twigletmac
jmarcv wrote:nielsene:
>The "User-Agent" aka browser is responsible for setting the HTTP_REFERER value.
Really??? I thought that came from Apache, since it is an apache enviornment variable!
God help us when we have to depend on browsers for data!
Definitely comes from the browser - that's why it's so unreliable.
Mac
Posted: Sun Aug 03, 2003 10:07 am
by jmarcv
twigletmac wrote:jmarcv wrote:
Definitely comes from the browser - that's why it's so unreliable.
Mac
Yow! So, what other 'Apache Enviornment' variables in PHP are there that don't come from Apache?
Posted: Sun Aug 03, 2003 2:11 pm
by Swede78
Yow! So, what other 'Apache Enviornment' variables in PHP are there that don't come from Apache?
The HTTP_REFERER variable is considered a "Server Variable" (
http://us4.php.net/manual/en/reserved.v ... les.server). It's not exclusive to Apache.
Posted: Sun Aug 03, 2003 3:10 pm
by nielsene
"Server Variables" are just things that PHP expects to have handed to it by the server. In this case Apache/IIS/etc attempts to extract the referrer field from the request and sets it up for php use when handing it over.
So yes, your webserver handles the parsing of the data, but its only as accurate as the value submitted by the user's browser.
This is true of almost all the server variables, the notable exceptions are those that start with "SERVER_*".
Posted: Sun Aug 03, 2003 6:27 pm
by jmarcv
nielsene
The PHP docs say:
Apache variables
These variables are created by the Apache webserver
.
and it doesn't elaborate.
So, it is very good to know. Thanks.