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
|
||||
$_SESSION["userlanguageid"] = $lang->getLanguageId();
|
||||
|
||||
$returnTo = "../";
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class LanguageUtils {
|
|||
}
|
||||
|
||||
$defaultlang = $this->getDefaultLanguage();
|
||||
$lang = $this->getLanguageById(@$_SESSION["userlanguageid"]);
|
||||
$lang = $this->getLanguageById(USER_LANGUAGE_ID);
|
||||
|
||||
if(!$lang && !$defaultlang) {
|
||||
throw new \Exception("Cannot get user or default language");
|
||||
|
|
|
@ -86,7 +86,7 @@ class TemplateUtils {
|
|||
|
||||
if($loadLangs) {
|
||||
$langUtils = LanguageUtils::i();
|
||||
$userlang = $langUtils->getLanguageById($_SESSION["userlanguageid"]);
|
||||
$userlang = $langUtils->getLanguageById(USER_LANGUAGE_ID);
|
||||
|
||||
if ($userlang === null) {
|
||||
$userlang = $langUtils->getDefaultLanguage();
|
||||
|
|
|
@ -50,14 +50,14 @@ if (!defined("DISABLE_CSRF_CHECK") &&
|
|||
|
||||
// Try to guess user language and store it
|
||||
// If the current language is not defined, or is invalid then return to default
|
||||
if(!isset($_SESSION["userlanguageid"])) {
|
||||
{
|
||||
$lang = LanguageUtils::i()->detectUserLanguage();
|
||||
|
||||
if(!$lang) {
|
||||
$lang = LanguageUtils::i()->getDefaultLanguage();
|
||||
}
|
||||
|
||||
$_SESSION["userlanguageid"] = $lang->getLanguageId();
|
||||
define("USER_LANGUAGE_ID", $lang->getLanguageId());
|
||||
}
|
||||
|
||||
// Shortcut to language functions
|
||||
|
|
Loading…
Reference in New Issue