title: Laravel: sending empty session on callback request
body: <p>i just create a custom <code>404.blade.php</code> page to show 404 error inside my layout and i made some changes in <code>app\Exceptions\Handler.php</code> file.</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>if ($exception instanceof TokenMismatchException){
  
       return redirect($request-&gt;fullUrl())-&gt;with('csrf_error',"Oops! Seems you couldn't submit form for a long time. Please try again.");
  }
  if($exception instanceof NotFoundHttpException){
       if(Auth::guard('org')-&gt;check() == false){
           return response()-&gt;view('errors.web-404', [], 404);
       }
  }else{
       if($exception instanceof \Illuminate\Validation\ValidationException || $exception instanceof MethodNotAllowedHttpException){
            return parent::render($request, $exception);
       }else{
            if(Auth::guard('org')-&gt;check()){
                  return response()-&gt;view('errors.error-page',['exception'=&gt;$exception,'request'=&gt;$request],500);
            }else{
                  return response()-&gt;view('errors.web-error-page',['exception'=&gt;$exception,'request'=&gt;$request],500);
            }                
       }
  }
  
  return parent::render($request, $exception);
  </code></pre>
  
  <p>It was showing <code>Auth::guard('org')-&gt;check()</code> always <code>false</code> because of session not start. So i did some changes in my <code>Kernel.php</code> file and all was working fine.</p>
  
  <p><strong>Kernel.php</strong></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,
  
      // Added to show 404 error inside layout
  
      \App\Http\Middleware\EncryptCookies::class,
      \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
      \Illuminate\Session\Middleware\StartSession::class,
  ];
  </code></pre>
  
  <p>But now I just noticed that all session flash messages and validation error messages are not working. I think it is because on <code>return back()</code> session again initialize in <code>Kernel.php</code></p>
  
  <p>Can any one tell me how i can solve this?</p>