2

I'm currently using Symfony 3.3.6 and experiencing some issues with flashbag messages.

The problem basically is;

The flashbag messages work in development environment, but does not in production/live environment.

$this->addFlash('success', 'Some kind of message');

The above code is being used in the controller to add the flashbag message.

{% for label, messages in app.flashes %}
{% for message in messages %}
    <div class="alert alert-{{ label }}">
        {{ message }}
    </div>
{% endfor %}{% endfor %}

Is the code which is being used in twig to retrieve the messages. Once again this works in dev environment, but for some reason does not in production.

In Flash-Messages in Symfony2 doesn't seem to work in my twig-template somebody states that: 'I just figure out that flash messages are not working if intercept_redirects is true in debug mode.' This is also the case in my configuration. But what does this option actually mean? I don't want to put simply intercept_redirects: false in the production config.yml as a fix, unless this is the real fix for the issue.

Thanks.

yceruto
  • 9,230
  • 5
  • 38
  • 65
Sino
  • 970
  • 3
  • 12
  • 27
  • Where `$this->addFlash('success', 'Some kind of message');` is called? under what conditions is called? have you tried `cache:clear` in prod? I can't reproduce your issue for 3.3.6 + prod env – yceruto Aug 17 '17 at 15:38
  • 1
    Also `intercept_redirects` is part of `web_profiler` configuration for dev env only, so it shouldn't affect you in prod env where the `WebProfilerBundle` is not loaded. – yceruto Aug 17 '17 at 15:43
  • $this->addFlash is called in the controller. Cache;clear did not change anything. The Flash messages do work, but only in dev mode. I did not change the default prod config settings. – Sino Aug 18 '17 at 09:10
  • Is working php session in production? – h3llr4iser Aug 18 '17 at 15:50

0 Answers0