title: Cannot retrieve cookies in codeigniter
body: <p>I am trying to have a login function in <strong>codeigniter</strong> model, but cannot retrieve cookies there.</p>
  
  <p>It returns bool false.</p>
  
  <p>I have tried searching for the problem,one of the problem was cookies were not being set,
  but my cookies are being set in the browser, under domain localhost. And I have tried using cookies on localhost earlier in a different project, without codeigniter, in which I was able to retrieve cookies on localhost.</p>
  
  <p>Here <code>$_COOKIE['username']</code> would throw error invalid index 'username', <code>$this-&gt;input-&gt;cookie('username')</code> would return <code>bool(false)</code>. But I can see 'username' cookie in my browser.</p>
  
  <p>Cookies set and retrieved are on different files.</p>
  
  <pre><code>public function checkLogin(){
  
      $this-&gt;load-&gt;helper('cookie');
  
      $row['user']    = $this-&gt;input-&gt;cookie('username', TRUE);
      $row['handle'] = $this-&gt;input-&gt;cookie('email', TRUE);
      $row['id']      = $this-&gt;input-&gt;cookie('pid', TRUE);
      $row['type']    = $this-&gt;input-&gt;cookie('type', TRUE);
      $row['slug']    = $this-&gt;input-&gt;cookie('slug', TRUE);
      $row['cuid']    = $this-&gt;input-&gt;cookie('cuid', TRUE);
  
      return  $this-&gt;input-&gt;cookie('username', false);
      }
  }
  </code></pre>
  
  <p>I set the cookies in a different file,</p>
  
  <pre><code>setcookie("username",$user, time()+60*60*60*24*30);
  setcookie("email",$handle, time()+60*60*60*24*30);
  setcookie("pid",$row['id'], time()+60*60*24*30*60);
  setcookie("type",$type, time()+60*60*24*30*60);
  setcookie("slug",$row['slug'], time()+60*60*24*30*60);
  setcookie("city",$row['city'], time()+60*60*24*60*30);
  setcookie("cuid", $code, time()+60*60*24*60*30);
  </code></pre>
  
  <p>Please ask for more information needed. I have used construct function(two underscores) in my controller, not in model. The form where cookies are being set is not in controller or model but in root folder. And I have tried setting cookies using <code>$this-&gt;input-&gt;set_cookie();</code> too.</p>