Laravel session does not work on another page

2

I'm working on a project with laravel, in it I created a session variable that takes a parameter from 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 it on another page I can not, could someone help me?

    
asked by anonymous 05.04.2016 / 20:52

1 answer

1

Laravel's session () works in a variety of ways, as we can see in the documentation . However, if you are using the default form you will need to reflash () or a keep in your session to keep on a next page:

$request->session()->reflash();

or

$request->session()->keep('lang');

Using $ request as the request variable.

I hope I have helped!

    
05.04.2016 / 21:35