• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

$HTTP_REFERER on win XP

Hi there,

I want to use the PHP variable $HTTP_REFERER fro checking if the user is come to a page from
my domain (just a security check). But looks like $HTTP_REFERER doesnot work on windows XP.

Any solution for this please?
0
storney
Asked:
storney
1 Solution
 
BatalfCommented:
Try

$_SERVER["HTTP_REFERER"];
0
 
BatalfCommented:
Newer versions of PHP doesn't support the direct $HTTP_REFERER.
0
 
storneyAuthor Commented:
Also tried using $_SERVER["HTTP_REFERER"]; doesn't  work
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
BatalfCommented:
ok, then try

$HTTP_SERVER_VARS['HTTP_REFERER']

0
 
BatalfCommented:
or

getenv('HTTP_REFERER')
0
 
storneyAuthor Commented:
sorry it doessn't work with any of the above
0
 
BatalfCommented:
Strange.

And I assume you have tried creating two pages where page 1 got a link to page 2 and in page 2 you output HTTP_REFERER? It would be empty otherwise.
0
 
storneyAuthor Commented:
oh yes!!!!
It shows the referer url on Win 98 but no output on XP
0
 
Diablo84Commented:
It is important to remember that the HTTP_REFERER is set client side and is not a reliable factor at the best of times. It may be that you have a program running that is blocking the referer from being sent on the XP machine... i vaguely recall one of our experts at some point indicating that one of the norton products blocks it from being sent. So, it may be worth while checking the configuration of any software you have installed that is related to the security of your machine, perhaps even any browser extensions you may have.

Unless you are using the referer in relation to observing incoming traffic from an external site i usually recommend a more reliable method using sessions. It works a little like this:

session_start();
if (isset($_SESSION['cur'])) $_SESSION['prev'] = $_SESSION['cur'];
$_SESSION['cur'] = $_SERVER['PHP_SELF'];

The above would go on every page (in an include file for convenience). If the current page has been assigned to the session variable 'cur' when the page loads then this value will be assigned to the session variable, 'prev'. After that the variable 'cur' will be updated with the current page. You can add more information into the current page variable such as the host, query string etc if you want the full page info. This means that the referering page will be available in $_SESSION['prev'] BUT will only work internally (ie. tracking pages around your site, not from or to external sites).

Diablo84
0
 
neesterCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept Diablo84's Solution

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

- Neester -
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now