Я не могу прочитать файл cookie, созданный с использованием компонента cookie CakePHP.
На самом деле куки создаются, и когда я отлаживаю сразу после метода записи, они отображают все куки. Но если я обновлю ту же страницу (действие), куки не читаются. На других действиях контроллера также куки не читаются.
var $components = array('Encryption','General','Cookie');
public function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow();
$this->Cookie->name =null;
$this->Cookie->time =2592000; // or '30 days'
$this->Cookie->path = '/';
$this->Cookie->domain = $_SERVER['HTTP_HOST'];
//$this->Cookie->secure = true; // i.e. only sent if using secure HTTPS
$this->Cookie->key = md5(uniqid(rand(), true));
//$this->Cookie->httpOnly = true;
$this->Cookie->type('aes');
}
public function index(){
$browserInfo=$this->General->getBrowser();
$browserName=$browserInfo['name'];
$cookie_value=md5(uniqid(rand(), true))."_".$browserName;
$knowTheBae= $this->Cookie->read('know_the_bae'); // this is returning null when i' refresh the page again.
if(count($knowTheBae)==0){
$this->Cookie->write('know_the_bae.identity',$cookie_value); //this line suppose to execute only first time. But it's executing every time i load this page .
debug($this->Cookie->read('know_the_bae')); //line no 43
}
if($this->Cookie->read('know_the_bae.identity')!=""){
if($this->Session->read('Auth.User.id')){
$this->Cookie->write('know_the_bae.user.name',$this->Session->read('Auth.User.username'));
$this->Cookie->write('know_the_bae.user.id',$this->Session->read('Auth.User.id'));
}else{
$this->Cookie->write('know_the_bae.user.name','UNKN_USR');
$this->Cookie->write('know_the_bae.user', array('name' => 'UNKN_USR', 'role' => 'guest'));
}
}else{
$this->Cookie->write('know_the_bae.identity',$cookie_value);
}
$this->Cookie->write("know_the_bae.test",'something going wrong');
debug($this->Cookie->read('know_the_bae')); //line no 59
}
вывод cookie браузера