Skip to main content
Blog General

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

Jothibasu J
July 25, 2017 |

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 2Tested 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/codeEx: Magento 2 root directory/app/code/Dckap/Rememberme

Step 2:

Create a registration.php file in the below path to define your Magento 2 extensionMagento 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 extensionMagento 2 root directory/app/code/Dckap/Rememberme/etc/module.xml

Step 4:

Create di.xml file in the below path to refer overriding classMagento 2 root directory/app/code/Dckap/Rememberme/etc/di.xmlNow DckapRemembermeControllerAccountLoginPost will be used to overrideMagentoCustomerControllerAccountLoginPost

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 https://github.com/jothibasuj/Remember-Me

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.

More posts by Jothibasu J