title: How to disable cookies in Laravel 5?
body: <p>I'm having single-page app made on Laravel 5.1. I use localStorage to keep API key and I don't need cookies. Laravel creates two cookies for me:</p>
  
  <ul>
  <li>XSRF-TOKEN</li>
  <li>laravel_session</li>
  </ul>
  
  <p>If I set <code>SESSION_DRIVER</code> to <code>array</code> in my environment config, <code>laravel_session</code> cookie is no longer generated.</p>
  
  <p>But I think there might be a problem with <code>XSRF-TOKEN</code> cookie, because I found out this piece of code in <code>VerifyCsrfToken</code> middleware class:</p>
  
  <pre><code>public function handle($request, Closure $next)
  {
      if ($this-&gt;isReading($request) || $this-&gt;shouldPassThrough($request) || $this-&gt;tokensMatch($request)) {
          return $this-&gt;addCookieToResponse($request, $next($request));
      }
  
      throw new TokenMismatchException;
  }
  </code></pre>
  
  <p>And <code>addCookieToResponse</code> method looks like this:</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(), time() + 60 * 120,
              $config['path'], $config['domain'], false, false
          )
      );
  
      return $response;
  }
  </code></pre>
  
  <p>It seems like it sets this cookie no matter what. I could disable this middleware, but I want to use it to verify CSRF token with HTTP headers. Can I disable cookies completely?</p>