title: Codeigniter cookie won't set
body: <p>For some reason I cannot set a cookie with an simple example. Every example I found on web failed too. I wonder if I miss something little. Keeps saying "<em>Cookie not set</em>"</p>
  
  <p>I added <em>REFRESH</em> after setting cookie and another method *get_language()* to read it via link clicking but still no luck.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>VIEW</strong></p>
  
  <pre><code>   &lt;p&gt;
      &lt;a href="&lt;?php echo site_url('welcome/set_language/english'); ?&gt;"&gt;English&lt;/a&gt;
      &lt;br /&gt;
      &lt;a href="&lt;?php echo site_url('welcome/set_language/spanish'); ?&gt;"&gt;Spanish&lt;/a&gt;
      &lt;/p&gt;
  
      &lt;br /&gt;
      &lt;p&gt;&lt;a href="&lt;?php echo site_url('welcome/get_language'); ?&gt;"&gt;Get Language&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>class Welcome extends CI_Controller
  {
      var $cookie_name    = 'language';
  
      public function __construct()
      {
          parent::__construct();
  
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;helper('cookie');
      }
  
      public function index()
      {
          $this-&gt;load-&gt;view('welcome_message');
      }
  
      public function set_language()
      {
          if($this-&gt;uri-&gt;segment(3) != false)
          {
              $cookie = array(
                              'name'      =&gt; $this-&gt;cookie_name,
                              'value'     =&gt; $this-&gt;uri-&gt;segment(3),
                              'expire'    =&gt; '86500',
                              'domain'    =&gt; '.language.com',
                              'secure'    =&gt; true
                              );
  
              set_cookie($cookie);
  
              redirect(null, 'refresh');
          }
      }
  
      public function get_language()
      {
          if (! get_cookie($this-&gt;cookie_name))
          {
              echo 'Cookie not set';
          }
          else
          {
              echo get_cookie($this-&gt;cookie_name);
          }   
      }
  </code></pre>
  
  <p>}</p>