Why not just pass the language in the URL? e.g. "example.com/index.php?lang=en"
Then in the code you just need to check if the lang param has been passed, else use the cookie, else use the default:
if (isset($_GET['lang']))
{
// return lang (convert it to entities
// to prevent any XSS attacks)
$lang = htmlspecialchars($_GET['lang']);
// store for next time
setcookie('lang', htmlspecialchars($_GET['lang']));
}
elseif (isset($_COOKIE['lang']))
{
// set lang var
$lang = $_COOKIE['lang'];
}
if (!isset($lang))
{
// if no $lang var set, use default
$lang = 'en';
}