Page 1 of 1
Alternative to HTTP_REFERER? It doesn't work on IE7, Opera
Posted: Fri Jan 12, 2007 3:43 am
by guarriman
Hi.
Working with PHP4, I created this PHP file:
Code: Select all
<html>
<li>REFERER: <?echo $_SERVER['HTTP_REFERER'];?>
<li><a href=ie7-referer.php>Click here</a>
</html>
It works ok (it shows webpage refererer) with most of web browsers, but not with IE7 or Opera.
Does anybody know an alternative to HTTP_REFERER to know the webpage the user come from?
Thank you very much,
Posted: Fri Jan 12, 2007 4:12 am
by Kieran Huggins
Please post the results of:
Copy and paste the code in, then the results out if you please.
Incidentally, it's technically considered bad practice to trust this particular variable. You may consider using a token of some sort instead.
Posted: Fri Jan 12, 2007 7:22 am
by guarriman
Code: Select all
Array ( [UNIQUE_ID] => qTMXt38AAAE37ApwEhcABAAJ [HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* [HTTP________] => ----:---------------------------------- [HTTP_ACCEPT_LANGUAGE] => en [HTTP_UA_CPU] => x86 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) [HTTP_HOST] => fooserver [HTTP_CONNECTION] => Keep-Alive [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 Server at fooserver Port 80 [SERVER_SOFTWARE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 [SERVER_NAME] => fooserver [SERVER_ADDR] => 192.160.2.3 [SERVER_PORT] => 80 [REMOTE_ADDR] =>
2c9d:a138:48f6:a2bf:302f:5600:a00:0 [DOCUMENT_ROOT] => /home/www [SERVER_ADMIN] => webmaster@mydomain.com [SCRIPT_FILENAME] => /home/www/tests/ie7-referer.php [REMOTE_PORT] => 1371 [REMOTE_USER] => mydomain [AUTH_TYPE] => Basic [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /tests/ie7-referer.php [SCRIPT_NAME] => /tests/ie7-referer.php [PHP_SELF] => /tests/ie7-referer.php [PATH_TRANSLATED] => /home/www/tests/ie7-referer.php [PHP_AUTH_USER] => john [PHP_AUTH_PW] => xxx )
The script name is 'ie7-referer.php', and I like to get 'back.html' (the URL containing the link to 'ie7-referer.php').
Posted: Fri Jan 12, 2007 7:30 am
by Kieran Huggins
can you post the source of that instead? It's a bit hard to read.
Posted: Fri Jan 12, 2007 9:17 am
by guarriman
Kieran:
Code: Select all
Array (
[UNIQUE_ID] => qTMXt38AAAE37ApwEhcABAAJ
[HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
[HTTP________] => ----:----------------------------------
[HTTP_ACCEPT_LANGUAGE] => en
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
[HTTP_HOST] => fooserver
[HTTP_CONNECTION] => Keep-Alive
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
[SERVER_SIGNATURE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4 Server at fooserver Port 80
[SERVER_SOFTWARE] => Apache/2.0.11 (Unix) DAV/2 PHP/4.4.4
[SERVER_NAME] => fooserver
[SERVER_ADDR] => 192.160.2.3
[SERVER_PORT] => 80
[REMOTE_ADDR] => 2c9d:a138:48f6:a2bf:302f:5600:a00:0
[DOCUMENT_ROOT] => /home/www
[SERVER_ADMIN] => webmaster@mydomain.com
[SCRIPT_FILENAME] => /home/www/tests/ie7-referer.php
[REMOTE_PORT] => 1371
[REMOTE_USER] => mydomain
[AUTH_TYPE] => Basic
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /tests/ie7-referer.php
[SCRIPT_NAME] => /tests/ie7-referer.php
[PHP_SELF] => /tests/ie7-referer.php
[PATH_TRANSLATED] => /home/www/tests/ie7-referer.php
[PHP_AUTH_USER] => john
[PHP_AUTH_PW] => xxx
)
Posted: Fri Jan 12, 2007 10:09 am
by feyd
If the browser doesn't send it, you're stuck.
If you control the referring page you can use sessions, cookies or the URL to pass the information if you feel it's that vital. If it's absolutely vital, your only option is sessions. The other two can easily be removed.
Posted: Fri Jan 12, 2007 2:24 pm
by bokehman
guarriman wrote:Code: Select all
Array (
[HTTP________] => ----:----------------------------------
)
Looks like the firewall/privacy software is blocking something there.