title: Laravel 5.4 - Session store not set on request
body: <p>On my Laravel 5.4 production server, I forgot to run the php artisan config:cache command after I implemented a multi authorization system.  It all works in my development environment, however it does not want to in production.  Since running the cache command, I’ve worked through all the errors to this point.  However I am stuck on this one and really not sure where to take it.  Any information I haven’t provided, please feel free to ask and I will post it.  Thank you so much for your help.</p>
  
  <pre><code>namespace App\Exceptions;
  
  use Exception;
  use Illuminate\Auth\AuthenticationException;
  use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  
  class Handler extends ExceptionHandler
  {
      protected $dontReport = [
          \Illuminate\Auth\AuthenticationException::class,
          \Illuminate\Auth\Access\AuthorizationException::class,
          \Symfony\Component\HttpKernel\Exception\HttpException::class,
          \Illuminate\Database\Eloquent\ModelNotFoundException::class,
          \Illuminate\Session\TokenMismatchException::class,
          \Illuminate\Validation\ValidationException::class,
      ];
  
      public function report(Exception $exception)
      {
          parent::report($exception);
      }
  
      public function render($request, Exception $exception)
      {
          return parent::render($request, $exception);
      }
  
      /**
       * Convert an authentication exception into an unauthenticated response.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Illuminate\Auth\AuthenticationException  $exception
       * @return \Illuminate\Http\Response
       */
      protected function unauthenticated($request, AuthenticationException $exception)
      {
          if ($request-&gt;expectsJson()) {
              return response()-&gt;json(['error' =&gt; 'Unauthenticated.'], 401);
          }
  
          $guard=array_get($exception-&gt;guards(),0);
  
          switch ($guard) {
              case 'admin':
                  $login='admin.login';
                  break;
  
              default:
                  $login='login';
                  break;
          }
          return redirect()-&gt;guest(route($login));
      }
  }
  
  
  namespace App\Http\Middleware;
  use Closure;
  use Illuminate\Support\Facades\Auth;
  
  class RedirectIfAuthenticated
  {
      public function handle($request, Closure $next, $guard = null)
      {
       switch ($guard) {
          case 'admin':
            if (Auth::guard($guard)-&gt;check()) {   
              return redirect()-&gt;route('admin');
                       }          
            break;
  
          default:
            if (Auth::guard($guard)-&gt;check()) {    
              return redirect('/user');
            }
            break;
        }
          return $next($request);
      }
  }
  
  
  
  namespace App\Http;
  
  use Illuminate\Foundation\Http\Kernel as HttpKernel;
  
  class Kernel extends HttpKernel
  {
      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,
      ];
  
      protected $middlewareGroups = [
          'web' =&gt; [
              \App\Http\Middleware\EncryptCookies::class,
              \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
              // \App\Http\Middleware\StartSession::class,
              \Illuminate\Session\Middleware\StartSession::class, 
              // \Illuminate\Session\Middleware\AuthenticateSession::class,
              \Illuminate\View\Middleware\ShareErrorsFromSession::class,
              \App\Http\Middleware\VerifyCsrfToken::class,
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
  
          'api' =&gt; [
              'throttle:60,1',
              'bindings',
          ],
      ];
  
      protected $routeMiddleware = [
          'auth' =&gt; \Illuminate\Auth\Middleware\Authenticate::class,
          'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
          'bindings' =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class,
          'can' =&gt; \Illuminate\Auth\Middleware\Authorize::class,
          'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
          'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
      ];
  }
  
  
  
  RuntimeException in Request.php line 388:Session store not set on request.
  1.  in Request.php line 388
  2.  at Request-&gt;session() in ShareErrorsFromSession.php line 42
  3.  at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  4.  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  5.  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
  6.  at StartSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  7.  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  8.  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
  9.  at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  10. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  11. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
  12. at EncryptCookies-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  13. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  14. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
  15. at Pipeline-&gt;then(object(Closure)) in Router.php line 561
  16. at Router-&gt;runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
  17. at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 498
  18. at Router-&gt;dispatch(object(Request)) in Kernel.php line 174
  19. at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
  20. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
  21. at TransformsRequest-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  22. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  23. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
  24. at TransformsRequest-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  25. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  26. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
  27. at ValidatePostSize-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  28. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  29. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
  30. at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 148
  31. at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
  32. at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
  33. at Pipeline-&gt;then(object(Closure)) in Kernel.php line 149
  34. at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 116
  35. at Kernel-&gt;handle(object(Request)) in index.php line 53
  </code></pre>