【发布时间】:2016-08-02 15:27:31
【问题描述】:
我需要在我的服务中创建一个 cookie
public function __construct(EntityManager $em, RequestStack $request)
{
parent::__construct();
$this->request = $request->getMasterRequest();
}
然后当我尝试在我的服务中的某个地方调用它时:
echo $this->request->cookies->get('_ga');die;
我得到了我手动创建的 cookie,但调用 ->set(key, val) 并没有保存我的 cookie
$this->request->cookies->set('test', time());
echo $this->request->cookies->get('test');
我有时间,但 cookie 只存在一次,在这个 webrequest 的范围内,如果我用 ->set 注释行,那么我应该看到时间没有改变,但我看不到它,因为 cookie 不是实际存储...有什么帮助吗?
【问题讨论】: