Try this in the include file:
<?php
if ((isset($_GET['lang']) && $_GET['lang'] != "")) {
setcookie("langpref", "".$_GET['lang'] ."", time()+(60*60*24*30), "/", "", 0);
$_COOKIE['langpref'] = $_GET['lang'];
}
?>
<?php
if (isset($_COOKIE['langpref'])) {
if (strpos($_SERVER['PHP_SELF'],$_COOKIE['langpref']) === false) {
header("location: /" . $_COOKIE['langpref'] ."/". basename($_SERVER['PHP_SELF']));
}
}
?>