I'm using Symfony 2.3.1 (this issue was also present in 2.2) with session.handler.pdo, but when I add a flash bag message like so:
$this->get('session')->getFlashBag()->add(
'success', "Your message has been sent."
);
return $this->redirect($this->generateUrl('home'));
It does not show on the home page after the redirect until I press refresh, then it shows up. So its taking 2 requests to be displayed. If I change the session storage back to native this problem is gone. Any ideas why this is happening?
I use the following to print the messages in Twig
{% for flashMessage in app.session.flashbag.get('success') %}
{{flashMessage}}
{% endfor %}
and my services is the same as the documentation as follows:
services:
pdo:
class: PDO
arguments:
dsn: "mysql:dbname=%database_name%"
user: %database_user%
password: %database_password%
calls:
- [setAttribute, [3, 2]] # \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
session.handler.pdo:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
arguments: ["@pdo", %pdo.db_options%]