title: CodeIgniter Cookie
body: <p>I'm having some trouble handling cookies. Initially I have set the cookie value to 0. When a user navigates to next page, I want to increment the cookie value by one. My controller is like this:</p>
  
  <pre><code>class Welcome extends CI_Controller {
  
      public function index() {
          $this-&gt;load-&gt;helper('cookie');
          $this-&gt;input-&gt;set_cookie("starttime", time(),time()+3600);
          $this-&gt;input-&gt;set_cookie("pagevisited",0,time()+3600);
          $_SESSION['currenttime'] = time();
          $this-&gt;load-&gt;view('indexpage');
      }
  
      public function page1() {
          $this-&gt;load-&gt;helper('cookie');
          $value = $this-&gt;input-&gt;cookie("pagevisited");
          $this-&gt;input-&gt;set_cookie("pagevisited",$value+1,time()+3600);
          $this-&gt;load-&gt;view('page1');
      }
  
      public function page2() {
          $this-&gt;load-&gt;helper('cookie');
          $value = $this-&gt;input-&gt;cookie("pagevisited");
          $this-&gt;input-&gt;set_cookie("pagevisited",$value+1,time()+3600);
          $this-&gt;load-&gt;view('page2');
      }
  }
  </code></pre>
  
  <p>The above code is not working. The cookie value is still 0. I noticed that CI is also storing session variables with the same cookie name. </p>