By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

I can not make the php script to reconize a variable

P: 1

I have a php script that should do that:
When a visitor come to my page from a referral get this referral and make a link to the domain of that referral on one of my pages. The ideea is that the link will last only the visitor is on the page

Here is the code:

if(!isset($_SESSION["origURL"])|| (trim($_SESSION["origURL"]) <> ''))
if ($_SERVER['HTTP_REFERER'] <>'')
$linkuri = $_SERVER['HTTP_REFERER'];
$x= strlen($linkuri)-7;
$linkuri = substr($linkuri,7,$x);
$vergoogle = substr($linkuri,0,10);
if($veryahoo <> '')
echo "<h3><a href='http://".$link."' target='_blank'>".$link."</a>";
echo "<h3><a href='http://".$link."' target='_blank'>".$link."</a>";

The idea is that the visitor will come directly to the page with this code(, after this start surfing my website and then if he come back to the he should see it link there.

As you can see I try to use a session variable, and when he first enter my site on the page I chek if $_SESSION["origURL"], and if not set in it the domain of the referral, after this the visitor will look over my other pages, and when he come back to check again if the $_SESSION["origURL"] is sent and if yes use the for createing the link.

Tha problem is that the first I open a browser and go directly to that page from google is ok, I got the link, but after I surf to my site and get back the link got my domain and not the firs referral.

On the second visit the $_SESSION["origURL"] is not set.

Thank you
Oct 11 '11 #1
Share this Question
Share on Google+
1 Reply

P: 59
bcos on coming back to ur site the same function that assigns the referrer overrides it. so i ll suggest u wrap it in an if statement
if($_SERVER['HTTP_REFERER'] != ''){


hope this is useful
Oct 13 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.