Seems I am doing something wrong, could someone point me in the right direction (version: 2.0.13)?
class TestController extends ControllerBase
{
public function setAction()
{
$this->view->disable();
// Set cookie
$this->cookies->set(
'test',
'This is the value',
time() + 3600,
'/',
false,
'localdomain.local',
true
);
// Redirect to deleteAction
$this->response->redirect('test/delete');
}
public function deleteAction()
{
$this->view->disable();
if ($this->cookies->has('test')) {
// Save to test session
$this->persistent->set('test', $this->cookies->get('test')->getValue());
// Delete cookie
$this->cookies->get('test')->delete();
}
// Redirect to checkAction
$this->response->redirect('test/check');
}
public function checkAction()
{
$this->view->disable();
// Saved value from the cookie, before we "deleted" it
echo 'Original value is: ', $this->persistent->get('test'), '<br />';
// Value should be empty, but echos "This is the value"
if ($this->cookies->has('test')) {
echo 'Current value is: ', $this->cookies->get('test')->getValue();
}
}
}
I get:
Original value is: This is the value
Current value is: This is the value