Solved

Set referer to something else when page loads

Posted on 2006-11-24
4
336 Views
Last Modified: 2012-06-27
Hi,

Lets say I have a page that loads and says "You came from XYZ". XYZ being the referer we just came from.

I want to blank out the referer variable when my page loads. When my page loads it should say "You came from <blank>"

What i'm trying to achieve is to stop all javascripts running on my page from getting my page referer.

Thanks
0
Comment
Question by:zattz
4 Comments
 
LVL 9

Expert Comment

by:lucki_luke
ID: 18010748
Hey,

in PHP you can modify the referer in the $_SERVER variable (if at all, read below):
$_SERVER['HTTP_REFERER']

Statement from the PHP documentation:
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

But I'm not sure about the javascript thing, because the javascript will run on the clients machine, thus in the browser and therefore it might be that the referer is not editable for the javascript part because the php stuff runs all on the server. This depends on how the javascript uses the referer.

Lukas
0
 
LVL 11

Accepted Solution

by:
ch2 earned 500 total points
ID: 18011212
You can't do that with Javascript or PHP.

Those headers are set by the client (browser) and recived by the server (webserver).
0
 
LVL 16

Expert Comment

by:HackneyCab
ID: 18011711
If you control those Javascript applications, why not just edit them to remove any reference to the referrer?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question