<?php
$lang = !empty($_GET['lang']) ? $_GET['lang'] : (!empty($_COOKIE['lang']) ? $_COOKIE['lang'] : substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
$lang = in_array($lang, $langArray) ? $lang : DEFAULT_LANG;
setcookie('lang', $lang, time() + 3600, '/');