title: Set a cookie in Laravel 5+ without response
body: <p>I'm trying to set a cookie in a function that's not going to return a response. The function is called from a middleware.</p>
  
  <p>Middleware:</p>
  
  <pre><code>// Verify user
          $userId = $userService-&gt;verify($email, $key);
          if ($userId) {
              $userService-&gt;authenticate($userId, $key);
  
              return $next($request);
          } else {
              return response('Unauthorized', 401);
          }
  </code></pre>
  
  <p>is calling $userService->authenticate:</p>
  
  <pre><code>// Get user
      $user = $this-&gt;getById($id);
      // Get user zipcode
      $user-&gt;zipcode = $this-&gt;getZipcodeById($id);
      // Set session
      Session::set('user', $user);
  
      if (!Cookie::has('user_forever')) {
        // SET COOKIE   
      }
  </code></pre>
  
  <p>I have tried to return a response in authenticate but it doen't work. I can't get it to work.. So I appreciates all help!</p>
  
  <p>Thanks in advance</p>