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.
Tested for Magento 2.1.6
Note: Please take necessary backups before you apply this code. Try it out on a development server first.
Create a custom module based on the Magento 2 structure in the folder app/code
Ex: Magento 2 root directory/app/code/Dckap/Rememberme
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
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
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
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.
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.