I'm making a multilanguage site, but I am having some trouble when changing language?

When a user click on a flag he has to refresh once before the language changes... How do I fix this?

PHP Code:
$lang urlencode($_GET['lang']);

setcookie("lang",$lang,time()-60*60*24*365,"/",".mypage.com",0);
setcookie("lang",$lang,time()+60*60*24*365,"/",".mypage.com",0);

$protocol $_SERVER['HTTPS'] == 'on' 'https' 'http';
$fullUrl $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

echo 
'<a href="'.$fullUrl.'&amp;lang=da"><img src="images/flags/flags_16x16/213.png" title="Danish" style="padding:1px;"></a>';
echo 
'<a href="'.$fullUrl.'&amp;lang=en"><img src="images/flags/flags_16x16/225.png" title="English" style="padding:1px;"></a>'