title: Creating middleware for all requests and setting session variable in laravel
body: <p>i am trying to set a session variable in middleware which i am trying to configure for all requests. I can`t seem to get it to work. The error is 
  RuntimeException in Request.php line 905:
  Session store not set on request.</p>
  
  <p>Maybe i am making a mistake when registering the middleware in kernel.php ?</p>
  
  <p>My Middleware code 
      
  
  <pre><code>namespace App\Http\Middleware;
  
  use Closure;
  use App\shoppingChart;
  
  class sessionChecker
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
  
         if(!$request-&gt;session()-&gt;has('test')){
             $request-&gt;session()-&gt;put('test','baran');
         }
  
         return $next($request);
      }
  }
  </code></pre>
  
  <p>My kernel.php is </p>
  
  <pre><code>&lt;?php
  
  namespace App\Http;
  
  use Illuminate\Foundation\Http\Kernel as HttpKernel;
  
  class Kernel extends HttpKernel
  {
      /**
       * The application's global HTTP middleware stack.
       *
       * These middleware are run during every request to your application.
       *
       * @var array
       */
      protected $middleware = [
          \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
          \App\Http\Middleware\sessionChecker::class,
      ];
  
      /**
       * The application's route middleware groups.
       *
       * @var array
       */
      protected $middlewareGroups = [
          'web' =&gt; [
              \App\Http\Middleware\EncryptCookies::class,
              \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
              \Illuminate\Session\Middleware\StartSession::class,
              \Illuminate\View\Middleware\ShareErrorsFromSession::class,
              \App\Http\Middleware\VerifyCsrfToken::class,
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
  
          'api' =&gt; [
              'throttle:60,1',
              'bindings',
          ],
      ];
  </code></pre>