Undefined property: App\Http\Controllers\MyController::$cookieJar
<p>So my controller looks as follows:</p>

<pre><code>use Illuminate\Http\Request;
use Illuminate\Cookie\CookieJar;
use Cookie;

class MyController extends Controller {

    public function __construct(CookieJar $cookieJar)
    {
        $this-&gt;id = $this-&gt;getID();
        $this-&gt;cookieJar = $cookieJar;
    }

    private function getID()
    {
        if (!isset($_COOKIE["ID"])){
            $id = 20;
            $this-&gt;cookieJar-&gt;queue('ID', $id, 60);
        }

        return $id;
    }
</code></pre>

<p>But I keep getting an error </p>

<blockquote>
  <p>Undefined property: App\Http\Controllers\MyController::$cookieJar</p>
</blockquote>

<p>In getID function.</p>

<p>What am I doing wrong? Would highly appreciate any possible help!</p>