Symfony2 : 阅读饼干
我已经在控制器操作中设置了几个cookie,然后在另一个操作中,我想读取cookie集并对值执行一些操作。但是,当尝试读取cookie时,我看到的只是一个空数组,我的代码如下:
public function testSetCookieAction()
{
$value = 'ABCDEFGHI'
$cookie = new Cookie('SYMFONY2_TEST', $value, (time() + 3600 * 24 * 7), '/');
$response = new Response();
$response->headers->setCookie($cookie);
$response->send();
.
.
.
}
public function testReadCookieAction()
{
$response = new Response();
$cookies = $response->headers->getCookies();
// $cookies = array(0) { }
}
当我,我看到有人知道我做错了什么吗?var_dump($_COOKIE);
array(1) { ["SYMFONY2_TEST"]=> string(9) "ABCDEFGHI" }
提前致谢