Disabling Remember Me in Fosuserbundle

Simple one for today!

For business apps, people are not really confident with the idea of using a “remember me” option on login. Because the security of your financial data prevails over the pain of logging in every time you want to use the app.

As I installed FOSUserBundle, the login form always shows a remember me checkbox. I wanted to not only get rid of that in the template, but also make sure that the possibility to do so was actually disabled server side.

Good news!

Although the checkbox always appears, the functionality is NOT provided by default. Remember me is a possibility that is already in the framework’s security component and therefore there’s nothing about it in FOSUserBundle more than just displaying the box in the template.

So if you want to enable it and not just have the checkbox, go have a look at http://symfony.com/doc/current/cookbook/security/remember_me.html to find out how to configure it properly.

If you don’t want it then?

So if you’re like me and do not want to allow users to use a remember me function, you probably do not want to display the check box as well. No reason to be tempting users with things they can’t actually do unless you’re eager to receive hundreds of feedback emails telling you that the “remember me” is broken and does not work.

All what’s left to do is remove it from the template. The default login template looks like this:

And actually there’s only about a thousand reasons you’d want to modify this template. Maybe the way it renders does not suit your application, and you wish to render it differently for example. Maybe you need to add css classes to some of the widgets in order to style it, maybe this maybe that!

To override it, add a similar template in

      ↪ Resources
        ↪ FOSUserBundle
            ↪ views
                ↪ Security

And name it login.html.twig. In my case this is the same template except I removed the checkbox.

Hope this helps!