title: How to retain Laravel 5 selected local language?
body: <p>For example, I log in and selected <code>en</code> as my language and then I select <code>zh</code> (chinese) and then log out. Is there any way to retain the localization after you log-out the app?</p>
  
  <p>this is the way I implement locale.</p>
  
  <p>web.php:</p>
  
  <p><code>Route::post('change-locale', 'LocaleController@changeLocale')-&gt;name('change.locale');</code></p>
  
  <p>LocaleController:</p>
  
  <pre><code>class LocaleController extends Controller
  {
      /**
       * @param Request $request
       */
      public function changeLocale(Request $request) {
  
          $this-&gt;validate($request, ['locale' =&gt; 'required|in:' . implode(',', config('app.available_locales'))]);
  
          Session::put('locale', $request-&gt;input('locale'));
  
          return redirect()-&gt;back();
      }
  
  }
  </code></pre>
  
  <p>Logout: </p>
  
  <pre><code>public function logout(Request $request)
      {
          $this-&gt;guard()-&gt;logout();
          $locale =  session('locale');
          $locale = Session::put('locale', $locale);
          Session::flush();
          //$request-&gt;session()-&gt;invalidate();
          //$request-&gt;session()-&gt;put('locale',$locale);
          return redirect('/login');
      }
  </code></pre>
  
  <p>Locale Setting: </p>
  
  <pre><code> public function handle($request, Closure $next)
      {
          if (Session::has('locale')) {
              $locale = Session::get('locale', Config::get('app.locale'));
          } else {
              $locale = substr($request-&gt;server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
  
              if (!in_array($locale, Config::get('app.available_locales'))) {
                  $locale = 'en';
              }
          }        
          App::setLocale($locale);
  
          return $next($request);
      }
  </code></pre>