开发者

CakePHP cookie expiration not working

Using AppController in CakePHP I set the followin开发者_如何学JAVAg cookie settings:

function beforeFilter() {
    $this->Cookie->name = 'Vinbeo';
    $this->Cookie->time = '7 Days';
}

I'm writing two cookies but only the first gets the right expiration time and the other expires when the browser is closed.

I'm using UsersController with this model:

$this->Cookie->write('name',$name);


Try this:

$this->Cookie->write('first_cookie', 'cookie1', false, '7 Days');
$this->Cookie->write('second_cookie', 'cookie2', false, '3 Days');

From here: The fourth parameter of write determines the expiry date. I think when you set properties like the way you are doing it now in the beforeFilter(), it does it only for the one cookie. Need to double check this though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜