当我从 PHP filegetcontents 方法调用路由时,设置 cookie 功能不起作用?它正在使用 jQuery $.ajax。我犯了什么错误?请帮我解决这个问题。
路线:
$api->addGet('/setmycookie/{cookievalue}', array('controller' => 'myController', 'action' => 'index'));
控制器:
public function indexAction($cookievalue) {
session_start();
$this->cookies->set('myCookie', $cookievalue, time() + 15 * 86400);
$this->cookies->send();
$this->response->setResponse(array("status" => "success"));
return $this->response;
}
前端触发器:
$data = filegetcontents("http://domain.com/api/setmycookie/mycookievalue");