Right, sorry, I've just read this properly.
The onclick event of an HTML element is a clientside event, you can only respond to it with clientside code, e.g. JavaScript.
(Note that you can set client cookies using JavaScript).
If you want to set a cookie for the language using PHP, you'll have to pass the language preference on the query string (using either $GET or $POST) and process it with the PHP script that is linked to by the a tag:
<?php
$flag = true;
if($lang == 'fr')
{
$flag = false;
}
?>
<a href="<?php
if(isset($_GET['s']))
$myURL = $myURL . 's=' . $_GET['s'];
if($true)
{
$myURL .= '&lang=fr';
}
else
$myURL .= '&lang=en';
echo $myURL;
?>">
Then the page which receives $myURL can use $GET['lang'] to determine the language and set_cookie('lang', $GET['lang']) to set a cookie for it.