I’m using Silex and I’m trying to clear a cookie. The docs provided for Silex about cookie control is poor, so I have relied on Symfony2 – unfortunately I can’t get it working!
$shop->match('/expire', function(Request $request) use ($app) {
$response = new Response();
$response->headers->clearCookie('order');
$response = $app['twig']->render('completed.html.twig');
return $response;
});
In another attempt I tried re-setting the cookie with a negative expire time, but that didnt work either. No errors at all.
Anyone got a clue what I’m doing wrong?
Thanks
You are creating a response object, setting the correct headers but then replacing it with a string of the content. Here is what you should do: