title: Localization laravel
body: <p>I have been trying to update language for the website.</p>
  
  <p>Controller</p>
  
  <pre><code>public function getUpdateLanguage(Request $request) {
          $request_data = $request-&gt;all();
           \Session::put('locale', $request_data['language']);
          return redirect()-&gt;back();
  }
  </code></pre>
  
  <p>Middleware:</p>
  
  <pre><code> public function handle($request, Closure $next)
   { 
      if ( \Session::has('locale')) {
          \App::setLocale(\Session::get('locale'));
      }
      return $next($request);
   }
  </code></pre>
  
  <p>But the true block for <code>if ( \Session::has('locale'))</code> never executes and the language is always 'en' and never updates. It works fine if I try </p>
  
  <pre><code> public function handle($request, Closure $next)
   { 
  
       \App::setLocale('arabic');
  
      return $next($request);
   }
  </code></pre>
  
  <p>kernel:</p>
  
  <pre><code>protected $middleware = [
          \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
          \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
          \App\Http\Middleware\TrimStrings::class,
          \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
          \App\Http\Middleware\TrustProxies::class,
          \App\Http\Middleware\Localization::class,
      ];
  </code></pre>
  
  <p>Localization is my middleware. The language update controller method redirects to home:</p>
  
  <pre><code>public function getIndex() {
          return view('frontend.home');
  }
  </code></pre>
  
  <p>Can someone please guide me where is the session value being cleared or if I am doing it wrong and there is a better way?</p>