First try using your client container (I assume you are using WebTestCase):
$client = static::createClient(); $container = $client->getContainer();
If it still does not work, try saving the session:
$session = $container->get('session'); $session->set('foo', 'bar'); $session->save();
I have not tried this in functional tests, but how it works in Behat steps.
source share