Magento 1 End of Life is here now. May be its time to plan Magento 1 to Magento 2 migration now. Let’s get started.

Sometimes a tiny feature makes a huge difference in our day-to-day tasks. They make our work simple and easy. One such feature is adding ‘Remember me – Username and Password’. This feature is so ubiquitous that we feel its absence only when it is not there.

This feature is not available by default in Magento 2. This blog provides the code to add  ‘Remember me – Username and Password’ feature in Magento 2.

Implementing the below code will let formsite remember your username and password so that you do not have to re-type them when returning to the site. We recommend only enabling this if you are not at a public computer and use a single formsite account. Cookies are required.

Migrate To Magento 2

Tested for Magento 2.1.6

Note: Please take necessary backups before you apply this code. Try it out on a development server first.

Step 1:

Create a custom module based on the Magento 2 structure in the folder app/code

Ex: Magento 2 root directory/app/code/Dckap/Rememberme

Step 2:

Create a registration.php file in the below path to define your Magento 2 extension

Magento 2 root directory/app/code/Dckap/Rememberme/registration.php

Step 3:

Create a module.xml file in the below path to define your Magento 2 extension

Magento 2 root directory/app/code/Dckap/Rememberme/etc/module.xml

Step 4:

Create di.xml file in the below path to refer overriding class

Magento 2 root directory/app/code/Dckap/Rememberme/etc/di.xml

Now Dckap\Rememberme\Controller\Account\LoginPost will be used to override


Step 5:

Create LoginPost.php file in the below path to define an overriding controller class

Magento 2 root directory/app/code/Dckap/Rememberme/Controller/Account

The code from line 153 and 159 is the customized extra code.

Step 6:

Create Helper file  in the following path…

Magento 2 root directory/app/code/Dckap/Rememberme/Helper/Data.php

Step 7 :

Please confirm the below changes in the customer login template file.

Ex – vendor/magento/module-customer/view/frontend/templates/form or extended login form template file.

After completing the above steps, run the below Magento 2 upgrade comment in the command prompt.

The code is available on GitHub at

Hope this helps. Let me know if you have any comments or suggestions.


  • Jothibasu J

    Jothibasu is a Senior Software Engineer with 6+ years of experience in PHP and Magento. His interests include playing volleyball during the weekends and watching science fiction movies. He is an active contributor to the Magento StackExchange forum.


Ready to drive online revenue

Get In Touch

4 thoughts on “How to Add ‘Remember me – Username and Password’ feature in Magento 2?

  1. Please remove this post. The code you have shown here violates all security rules. You provide secure customer data like email and password in the cookie. Some developer might use this code on production and create a big security whole in the merchant system.

  2. you shouldn’t directly edit Magento core files, as you said in step 7, i think you need to override it in a custom theme or module !

Leave a Reply

Your email address will not be published. Required fields are marked *