How to establish and destroy a session on the controller side?I tried to the side of view, it works fine. But now it is necessary from within the controller.
I finally found a solution here. Use the "session" service described here: Old post
UPDATE:
Destroy a session in Symfony 2 as follows:
$request->getSession()->invalidate(1);
As invalid, robs the current session intact, if you do not provide any parameter, you need to set the life expectancy to 1 (one second)
Symfony 3.4 documentation: http://api.symfony.com/3.4/Symfony/Component/HttpFoundation/Session/Session.html#method_invalidate
Have you tried
/** @var $session Session */ $session = $request->getSession(); $session->remove('name');
You tried
$this->getAttributeHolder()->remove('foo');
if it was saved in the foobar namespace
$ user-> getAttributeHolder () → delete ('Foobar', '', 'Foo');