title: “How to fix ‘Trying to get property 'headers' of non-object” VerifyCsrfToken
body: <p>I run my project and i get this error:</p>
  
  <blockquote>
    <p>Trying to get property 'headers' of non-object in
    "\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php"</p>
  </blockquote>
  
  <p>in this function</p>
  
  <pre><code>    protected function addCookieToResponse($request, $response)
      {
          $config = config('session');
  
          $response-&gt;headers-&gt;setCookie(
              new Cookie(
                  'XSRF-TOKEN', $request-&gt;session()-&gt;token(), $this-&gt;availableAt(60 * $config['lifetime']),
                  $config['path'], $config['domain'], $config['secure'], false, false, $config['same_site'] ?? null
              )
          );
  
          return $response;
      }
  </code></pre>