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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -