php - Why can't I create cookies in Symfony 2? -
for reason, can't seem create cookies using symfony 2. controller:
public function indexaction() { var_dump($this->getrequest()->cookies->all()); $response = new response(); $response->headers->setcookie(new cookie('foo', 'bar')); var_dump($response->headers->getcookies()); return $response; }
when run controller, see expect: array containing "phpsessid" cookie , array containing new cookie i'm trying create. when reload page, expect see new cookie in first array, don't. nothing changes on reload.
can spot i'm doing wrong? i've been staring @ these lines 15 minutes now.
your first var_dump()
sending content, further headers cannot sent. remove , code work.
Comments
Post a Comment