title: Why do I get an error in Laravel when session has timed out and I try to log out beyond that time
body: <p>I am running Laravel 6 on Homestead. I have seen similar errors here but none specific to my situation. </p>
  
  <ul>
  <li>If I log in, that's fine. </li>
  <li>If I log out straight away, that fine too.</li>
  <li>If I leave the screen to timeout beyond the session_lifetime set in .env, it wont log out without this error. </li>
  </ul>
  
  <pre><code>Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() 
  must be an instance of Symfony\Component\HttpFoundation\Response, string given, 
  called in /home/vagrant/code/MySite/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php on line 60
  </code></pre>
  
  <p>I'm learning Laravel and coming from vanilla php, I haven't a clue where to start looking. Thanks in advance.</p>
  
  <p>I dont have access to login routes am using Auth:routes() in web.php. I think i may have solved the problem by overriding logout(). Seems a bit to simplistic. Wonder if this is secure?</p>
  
  <pre><code>    public function logout(Request $request){
      Auth::logout();
      return  redirect()-&gt;route('home');
      }
  </code></pre>
  
  <p>Edit, sorry that does not solve my problem. It works within active session time but outside that i have same problem</p>
  
  <p>Unfortunately, that does not work for me. I see the logic why it should but same error shows. As an experiment, I just returned "hello world" on its own in logout method and sure enough it just shows up on logout page no errors. But if I do this I get the same error as above (no logout functions just a rtn view)</p>
  
  <pre><code>    public function logout(Request $request){
        //if (Auth::check()) {
        //  Auth::logout();
        //}
        //return  redirect()-&gt;route('home');
        //$request-&gt;session()-&gt;flush();
        return view('front.pages.aboutus');
        //return  "hello world";
      }
  </code></pre>
  
  <p>As you can see I have been experimenting with flush() too but no joy.</p>