Zend framework2 ZF2-如何在模型内设置cookie?
我尝试在模型中设置cookie,但它似乎不起作用。有什么想法吗Zend framework2 ZF2-如何在模型内设置cookie?,zend-framework2,Zend Framework2,我尝试在模型中设置cookie,但它似乎不起作用。有什么想法吗 $header = new \Zend\Http\Header\SetCookie(); $header->setName('Token'); $header->setValue($token); $header->setPath('/'); $header->setDomain('localhost'); $header->setExpires(time()+(3600*24*365)); $cli
$header = new \Zend\Http\Header\SetCookie();
$header->setName('Token');
$header->setValue($token);
$header->setPath('/');
$header->setDomain('localhost');
$header->setExpires(time()+(3600*24*365));
$client = new \Zend\Http\Client();
$client->addCookie($header);
您需要将头添加到HTTP响应对象,而不是HTTP客户端的随机实例 不过,该模型可能并不适合这种情况。根据您正试图执行的操作,我建议您返回令牌,以便您可以在控制器操作中设置此cookie