当我调用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");