开发者

Cakephp doesn't write a cookie

开发者 https://www.devze.com 2022-12-29 16:42 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消