What is the best way to notify a user after an access_control rule redirects?

So after quite a bit of research, I found the right way to do this. You’ll need to use an Entry Point service and define it in your firewall configuration. This method will not mess with your default page settings specified in your firewall config for logging in. The Code security.yml: firewalls: main: entry_point: entry_point.user_login … Read more

Get current URL in Twig template?

{{ path(app.request.attributes.get(‘_route’), app.request.attributes.get(‘_route_params’)) }} If you want to read it into a view variable: {% set currentPath = path(app.request.attributes.get(‘_route’), app.request.attributes.get(‘_route_params’)) %} The app global view variable contains all sorts of useful shortcuts, such as app.session and app.security.token.user, that reference the services you might use in a controller.

Accessing session from TWIG template

{{app.session}} refers to the Session object and not the $_SESSION array. I don’t think the $_SESSION array is accessible unless you explicitly pass it to every Twig template or if you do an extension that makes it available. Symfony2 is object-oriented, so you should use the Session object to set session attributes and not rely … Read more