2
다음 코드를 사용하여 설정하고 CakePHP에서 쿠키를 읽습니다.CakePHP 쿠키가 설정되지 않음
public $components = array('Cookie');
public function beforeFilter(){
parent::beforeFilter();
$this->Cookie->name = 'saved_times';
$this->Cookie->time = '1 year';
$this->Cookie->domain = 'localhost';
$this->Cookie->path = '/';
$this->Cookie->httpOnly = false;
$this->Cookie->key = '+%)asG_~s*SAr&[email protected]@[email protected][email protected]*(XSL#$XOw!a232d#HKis~#^';
$this->Cookie->secure = false;
}
public function save_position($time){
if($this->Auth->user('id')){
//save to the database
return true;
}else{
//set browser cookie
$this->Cookie->write('time', $time);
echo "set", $this->Cookie->read('time');
}
}
public function read(){
echo $this->Cookie->read('time'), "test";
print_r($this->Cookie->read('time'));
}
문제는 내가 볼 수있는 쿠키를 설정할 때, "설정"및 쿠키 값이 밖으로 반향 것입니다,하지만 난 단지 '테스트'없이 쿠키 값을보고 있어요 /read/
를 방문 할 때. 또한 Chrome에서 쿠키 뷰어를 사용하지만 saved_times
이 아닌 내 도메인에 대한 쿠키는 CAKEPHP
입니다. 나는 쿠키가 설정되어 있다고 생각하지 않는다. 그러나 왜 그런지 모르겠다.
고맙습니다. 내 문제가 해결되었습니다. – romellem