The fb_ref variable in a Facebook referrer URL

First I added a Facebook Like button to my website. Then I clicked the button and it added the entry onto my Wall as it should. When I hover my mouse over the link it shows:

http://www.oil-testimonials.com/likeButton.php?fb_ref=110&fb_source=profile_multiline

However, when I click on it and then view the session variables on my website it shows the following for the referrer:

http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.oil-testimonials.com%2FlikeButton.php%3Ffb_ref%3D110%26fb_source%3Dprofile_multiline&h=zAQDJkkeA

In my header.php file I have been unable to grab the ref variable that Facebook sends using the following code:

if (isset($ref)) {

$_SESSION['facebook'] = $ref;
}

Do I need to convert the referral address into one that does not use the % codes first? Is that why it’s not working for me?

Thanks!

$ref would refer to a variable that already exists in the script, not anything input from Facebook.

Shouldn’t you be grabbing something via the query string $_GET[‘’] or a session variable first?

And to be clear, are you using the Legacy function as explained here http://developers.facebook.com/docs/reference/fbml/ref/ but not using a javascript handler to process it?