Solved

Set referer to something else when page loads

Posted on 2006-11-24
4
335 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

776 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