Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing HTTP_REFERER manually

Status
Not open for further replies.

Anthonyjm

Programmer
Aug 30, 2005
3
US
Is there anyway to manually pass a value for $ENV{'HTTP_REFERER'} to a page a user is forwarded to?

I wrote a Perl CGI script that validates base on username and password and forwards to user to different sites. Problem is one of these sites uses the HTTP_REFERER variable to validate users from my site. Because I use:
print "Location: $url\n\n";
to forward the users, HTTP_REFERER is left blank.

Any ideas would be welcome.
(Great site, btw)
Anthony
 
maybe you can set it in Javascript?

this is how you can access it:-

//Get the value of the referer request header
String reflink = request.getHeader("referer");



Kind Regards
Duncan
 
The url doesn't matter. It could be anything, for example. The script just doesn't send a HTTP_REFERER value.

I don't think I can use javascript because the "Location:" takes the place of the header. So it basically reads this one line and forward the user to whatever URL is indicated.

Thanks for the replies,
Anthony
 
From the documentation I've read, it doesn't look like redirecting the page ever sends the HTTP_REFERER variable.

Why not do something like the following:

Code:
<html>
<head>
<script type="JavaScript">
function redirectPage()
{
    document.forms[0].submit();
    return true;
}
</script>
</head>
<body onLoad="redirectPage();">
<form action="$url">
</form>
<h2>Redirecting to new website</h2>
</body>
</html>

Kind of a messy implementation, but it basically submits a form to the new URL as soon as the page finishes loading. Thus, getting the HTTP_REFERER environment variable to appear.

- Rieekan
 
Thanks, but I was just hoping to avoid the user seeing any intermediate pages. I read through the documentation too, I was just hoping there was a way around it. Thank again for the feed back.

Anthony
 
You could take out the Header tag (I just used that when I did my test of the page) and the only thing the user will see is a blank page for an instant. Then they'll be taken to the new URL.

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top