Don't store user language in session
So that we don't save it in every session on every page visit. Cookies are enough to remember selected language.
This commit is contained in:
parent
8c93d31321
commit
83d7d0b970
|
@ -19,7 +19,6 @@ if ($lang === null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setcookie("tswebsite_language", $lang->getLanguageCode(), time() + (60 * 60 * 24) * 60, "/"); // 60 days
|
setcookie("tswebsite_language", $lang->getLanguageCode(), time() + (60 * 60 * 24) * 60, "/"); // 60 days
|
||||||
$_SESSION["userlanguageid"] = $lang->getLanguageId();
|
|
||||||
|
|
||||||
$returnTo = "../";
|
$returnTo = "../";
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ class LanguageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultlang = $this->getDefaultLanguage();
|
$defaultlang = $this->getDefaultLanguage();
|
||||||
$lang = $this->getLanguageById(@$_SESSION["userlanguageid"]);
|
$lang = $this->getLanguageById(USER_LANGUAGE_ID);
|
||||||
|
|
||||||
if(!$lang && !$defaultlang) {
|
if(!$lang && !$defaultlang) {
|
||||||
throw new \Exception("Cannot get user or default language");
|
throw new \Exception("Cannot get user or default language");
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TemplateUtils {
|
||||||
|
|
||||||
if($loadLangs) {
|
if($loadLangs) {
|
||||||
$langUtils = LanguageUtils::i();
|
$langUtils = LanguageUtils::i();
|
||||||
$userlang = $langUtils->getLanguageById($_SESSION["userlanguageid"]);
|
$userlang = $langUtils->getLanguageById(USER_LANGUAGE_ID);
|
||||||
|
|
||||||
if ($userlang === null) {
|
if ($userlang === null) {
|
||||||
$userlang = $langUtils->getDefaultLanguage();
|
$userlang = $langUtils->getDefaultLanguage();
|
||||||
|
|
|
@ -50,14 +50,14 @@ if (!defined("DISABLE_CSRF_CHECK") &&
|
||||||
|
|
||||||
// Try to guess user language and store it
|
// Try to guess user language and store it
|
||||||
// If the current language is not defined, or is invalid then return to default
|
// If the current language is not defined, or is invalid then return to default
|
||||||
if(!isset($_SESSION["userlanguageid"])) {
|
{
|
||||||
$lang = LanguageUtils::i()->detectUserLanguage();
|
$lang = LanguageUtils::i()->detectUserLanguage();
|
||||||
|
|
||||||
if(!$lang) {
|
if(!$lang) {
|
||||||
$lang = LanguageUtils::i()->getDefaultLanguage();
|
$lang = LanguageUtils::i()->getDefaultLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["userlanguageid"] = $lang->getLanguageId();
|
define("USER_LANGUAGE_ID", $lang->getLanguageId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shortcut to language functions
|
// Shortcut to language functions
|
||||||
|
|
Loading…
Reference in New Issue