It drives me crazy. In my AppController, I have the following:
public function beforeFilter() { $this->Cookie->name = 'MyCookie'; $this->Cookie->time = '1 year'; $this->Cookie->domain = 'http://mydomain.com'; $firstVisit = $this->Cookie->read('foo'); if ( empty($firstVisit) ) { $this->set('firstVisit', true); $this->Cookie->write('foo', 'true'); } else { $this->set('firstVisit', false); } }
It seems like it should work, but nothing is returned and the cookie is completely empty.
What could prevent Cake from actually saving cookies?
source share