title: Cookie::get() return null
body: <p>I have problems getting Cookie, I define a cookie in one middleware "CheckReferral", but when I call the cookie in one Controller the cookie return null, I check the cookie in the browser, and the cookie is good in the browser, I don't know what is the problem with the cookie... I've googled too much and this is my last resource, Someone can help me?</p>
  
  <p>Here is the code of the middleware:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Middleware;
  
  use Closure;
  
  class CheckReferral
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          if ($request-&gt;hasCookie('referral')) {
              return $next($request);
          } else {
              if ($request-&gt;query('ref')) {
                  return redirect($request-&gt;fullUrl())-&gt;withCookie(cookie()-&gt;forever('referral', $request-&gt;query('ref')));
              }
          }
  
          return $next($request);
      }
  </code></pre>
  
  <p>This is how I call the cookie in the controller:</p>
  
  <pre><code>protected function create(array $data)
  {
      // $referred_by = User::where( 'affiliate_id', Cookie::get( 'referral' ) )-&gt;first();
      // $referred_user = Cookie::get( 'referral' );
  
      return User::create([
          'name'         =&gt; $data['name'],
          'email'        =&gt; $data['email'],
          'password'     =&gt; bcrypt($data['password']),
          'affiliate_id' =&gt; $this-&gt;uniqueRandomString(),
          'referred_by'  =&gt; Cookie::get('referral'),
      ]);
  }
  </code></pre>
  
  <p>Here is the cookie stored in the browser:</p>
  
  <p><a href="https://i.stack.imgur.com/MkUah.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MkUah.png" alt="Why I can&#39;t use this stored? "></a></p>
  
  <p>Here is the database... the field referred_by, is stored as null, but should store the Value of the cookie:</p>
  
  <p><a href="https://i.stack.imgur.com/d0wBp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d0wBp.png" alt="Why the cookie return null?"></a></p>
  
  <p>Thank a lot, I hope resolve the problem, and know the cause... </p>