Adding specific variable to every link on page?!?!

Is it possible to add a specific variable on each link in the entire page without hardcoding it…

Lets say I have some links like this:

Now what I want is to add this variable:

To each link without having to type it… Is that possible?

Thanks in advance :wink:

If you need it on every single page on your site, why does it need to be a variable?

Just set a constant and make it available to your scripts.

Not sure what you mean?

Well the staticvar is only uses sometimes…

$staticvar = urlencode($_GET['staticvar']); 

Well, in this way you can say that its not a staticvar?!? The variable could change, but it is important to get on every link on the page… But how?

Why not use a $_SESSION?

You’d still need to do this to pass the session hash for browsers with sessions disabled, but that’s maybe .001% of users.

Hmmm, not sure how to do this. What I’,m trying to accomplish is to choose 2 different css styles depending on how the user is getting to my page. My page is made like a basic page and a facebook app.

I want to be able to determine if the user is watching the page from facebook or not. Untill now I have tryid to do so by adding an variable to all my links (&app=‘.$app.’) and then doing this:

$app = urlencode($_GET['app']);

if ($app == 'fb'){
} else {

But the problem here is that I have to many links in my page to alter them all… Can this still be done with $_SESSION and if yes… How?

Although not the most reliable thing in the world, $_SERVER[‘HTTP_REFERER’] should help. I say not the most reliable because the user can remove its contents if they browse in privacy mode.

Remember to filter the input of any $SERVER['HTTP*'] variable as the browser set their values making them subject to attack by an attack script (SQL injections, that sort of nonsense).

The problem with this is that the facebook app is within a iframe and doesn’t give any feedback within facebook?!?!

Any ideas?