Im using codeigniter 2.2.0 , I want to set cookie and get it in another contoller ! but it does not get cookie !! I set in autoload.php
:
$autoload['helper'] = array('url','cookie');
my code in controller/welcom.php
:
class Welcome extends CI_Controller {
public function index()
{
$cookie = array(
'name' => 'hello',
'value' => 'Im content for soheil',
'expire' => 3600
);
$this->input->set_cookie($cookie);
}
}
anfd before that I set in config/config.php
this values :
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "localhost";
$config['cookie_path'] = "/ci2.2/";
$config['cookie_secure'] = TRUE;
for localhost
and /ci2.2/
: I've create a normal php cookie and in firefox I found this information for it ! while I have tested it whith this code :
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "";
$config['cookie_secure'] = TRUE;
afterI open welcome
page I can see that the cookie has been created i firefox cookies , but when I want to get it by this code in another conroller by this code :
class Soheil extends CI_Controller {
public function index()
{
echo 'coolie is : '.$this->input->cookie('hello');
}
}
it returns NULL
while I see the cookie is seted in firefox :
name : hello
Content : Im content for soheil
Path :/ci2.2/
send for : Encrypted connections only
expires :Saturday, March 21, 2015 11:44:00 PM
I have read this questions : Why doesn't cookie work in CodeIgniter? - Setting cookies not working in CodeIgniter - Cookie not working with Login System CodeIgniter
but still I have my problem