Cakephp doesn't write a cookie
I have a problem with writing cookies in cakephp and even 开发者_如何学运维don't know how to debug it or where too look for a clue.
I've inherited a project where cookie were only created using the Session component, of course i added 'Cookie' to $components array in app_controller and put this in beforeFilter:
$this->Cookie->name = 'foo';
$this->Cookie->path = '/home/~nick';
$this->Cookie->domain = 'hostname';
$this->Cookie->secure = false; //i.e. only sent if using secure HTTPS
$this->Cookie->key = 'some key';
and in some action i use:
$this->Cookie->write('key', 'value');
I access page by http://hostname/home/~nick/foo and actually try to put even something so silly. I doesn't work. I would be really gratefully for any clue where to search problem. Thanks!
Your domain value was probably wrong making the cookie unavailable. Leaving it blank probably defaults to the current domain.
精彩评论