2
I am working on a project with Laravel, in it I created a session variable that takes a parameter of the url as follows:
if(!empty(Input::get('lang'))){
$lang = Input::get('lang');
Session::put('lang', $lang);
} else {
$lang = "es";
Session::put('lang', $lang);
}
if(Session::get('lang') == 'pt-br'){
App::setLocale("pt-br");
}
That way the session is only working on this page, when I try to use on another page I can’t, someone could help me?
Look in the config folder for the file Session.php and see its Lifetime.
– Diego Souza
It’s at the default value, 120. Even if I change it to a very high value it’s still the same.
– Luciano Alexandre
It comes empty on the other page ?
– Diego Souza
The return is NULL.
– Luciano Alexandre
There is some logic error there! check the code better, or else put all the code!
– novic
@Lucianoalexandre a tip would be you create a middleware to do this language treatment, in middleware you can take the lang parameter in the URL and set the correct language and if you do not have the parameter you arrow the default language.
– Kayo Bruno