/**
  * This method checks whether the given language is available.
  * If this is the case, it sets it into the cookie / session.
  * Otherwise, the default language is used.
  * @param lang new language to use
  * @return language after changing
  */
 public static function handleLanguageChange($lang)
 {
     $languages = LanguageHelper::getLanguages();
     if (in_array($lang, $languages)) {
         $_SESSION[Session::LANGUAGE] = $lang;
         setcookie(Session::LANGUAGE, $lang, time() + Config::COOKIE_LIFETIME);
     } else {
         $_SESSION[Session::LANGUAGE] = Config::DEFAULT_LANGUAGE;
         setcookie(Session::LANGUAGE, Config::DEFAULT_LANGUAGE, time() + Config::COOKIE_LIFETIME);
     }
     return $_SESSION[Session::LANGUAGE];
 }