Skip to content
Advertisement

How to spoof site referrer?

I have 2 pages :

1.php and 2.php

When the user arrives on 2.php, i want to show on 2.php that the user is arriving from google.com and NOT from 1.php

I tried spoofing the header of 2.php using

<?php
header();
?>

when i do a javascript document.write(document.referrer); it shows me 1.php

Any help is appreciated.

Advertisement

Answer

The http referrer is a request header. The server (PHP) can only set response headers.

Thus the only way to spoof a referrer is for the client to do it, usually via some sort of browser plugin.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement