Question

I am using javascript to get the referring page (document.referrer) which works fine and I can add this value to a div no problem.

How do I assign this value to a PHP variable in order to do some other things with it?

Ideally, something like:

$myphpvariable  = document.referrer;
Was it helpful?

Solution

what about

$myphpvariable = $_SERVER['HTTP_REFERRER'];

?

OTHER TIPS

You can use

$_SERVER['HTTP_REFERER']

and since this is PHP this happens on the server side.

More info: $_SERVER in PHP

As a side note REFERER is sent by the user agent as part of the HTTP request - do not rely on it to be truthful!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top