Skip to content

Instantly share code, notes, and snippets.

@arsisakarn
arsisakarn / gist:1450450
Last active June 4, 2018 18:05
Symfony 2 set and read cookie
<?php
public function testSetCookieAction()
{
$value = '12345';
$html = '<html><body>test set cookie varName =' . $value . '</body></html>';
$response = new Response($html);
$response->headers->setCookie(new Cookie('varName', $value, time() + (3600 * 48)));
return $response;
}