Попробуйте вот так
<?php
$langTime = time() + 3600*24*31*100;
if(isset($_GET['lang'])) {
setcookie("lang", $_GET['lang'], $langTime);
header('Location: '.$_SERVER['HTTP_REFERER'] );
die();
}
if (isset($_COOKIE["lang"])) {
switch ($_COOKIE["lang"]){
case "rus":
define("LANG","rus");
break;
case "eng":
define("LANG","eng");
break;
default:
setcookie("lang", "rus", $langTime);
header('Location: '.$_SERVER['HTTP_REFERER'] );
die();
break;
}
} else {
preg_match('/^\w{2}/',$_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
switch (strtolower($matches[0])){
case "ru":
define("LANG","rus");
break;
case "en":
define("LANG","eng");
break;
case "us":
define("LANG","eng");
break;
default:
define("LANG","rus");
break;
}
}
include_once 'lang/lang_'. LANG .'.php';
<a href="index.php?lang=rus"><img src="img/flags/RU.gif" align="right" title="Russian"></a>
<a href="index.php?lang=eng"><img src="img/flags/GB.gif" align="right" title="English"></a>