This is a discussion on How to get referrer parameters? within the PHP Language forums, part of the PHP Programming Forums category; If a referrer contains parameters, and I'd like to save these in a cookie, is this possible? I may ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
If a referrer contains parameters, and I'd like to save these in a
cookie, is this possible? I may have a banner at www.yahoo.com, this may include a link like www.mysite.com/index.html?banner=mail&color=red If I use the regular PHP parameter for referrer it gets only www.yahoo.com, is it possible to make it store the parameter in the link banner=mail&color=red or www.mysite.com/index.html?banner=mail&color=red? Thus not just the referrer, but what the referring site requested/linked to at mysite.com? |
|
|||
|
Jan wrote:
> If a referrer contains parameters, and I'd like to save these in a > cookie, is this possible? > When provided, its value is stored in the following variable: $_SERVER['HTTP_REFERER'] And yes, it's misspelled... JW |
|
|||
|
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:440ac9eb$0$71441$dbd41001@news.euronet.nl... > Jan wrote: >> If a referrer contains parameters, and I'd like to save these in a >> cookie, is this possible? >> > > When provided, its value is stored in the following variable: > $_SERVER['HTTP_REFERER'] > > And yes, it's misspelled... That wasn't the question, rather collecting the get string from the referrer. However I believe PHP trims the referrer to show only the URI, not the whole request string. If you have access to log files you could use these to parse out the referrers, but that's only really helpful *after* the event, because the server will probably lock them until they are next rotated. Jon |
|
|||
|
Jonathan Wiltshire wrote:
> That wasn't the question, rather collecting the get string from the > referrer. However I believe PHP trims the referrer to show only the > URI, not the whole request string. If you have access to log files > you could use these to parse out the referrers, but that's only > really helpful *after* the event, because the server will probably > lock them until they are next rotated. > When the link to the PHP script is called from a page which itself is called with a query string and the link is clicked, the $_SERVER['HTTP_REFERER'] variable will contain the full URL, including the query string of the originating page. However, this is not the query string sent to the PHP script. So, when the page containing the link is called with http://domain/?a=b and the link is clicked sending the query string "foo=bar", the called PHP script will receive http://domain/?a=b as the referrer (stored in the $_SERVER['HTTP_REFERER'] variable) and the query string "foo=bar" will be stored in $_GET, $_REQUEST or $_SERVER['QUERY_STRING'] as usual. JW |