Sunday, April 17, 2016

How to solve Magento admin panel log in problem on localhost XAMPP

Most of the developers install Magento on local servers such as XAMPP, WAMP etc. One common problem that arises after such installation is that the admin is not able to log into the admin panel (backend panel) even after entering the correct username and password. Let's try to understand what the problem is below:

The Problem:

1. Magento admin tries to log into the admin panel by going to url- localhost/magento/index.php/admin . Then this screen appears:-

2. The admin tries to enter the correct username and password. Even after entering the correct username and password combination, the page just reloads back. No incorrect password or username warning is displayed. that means the username and password are surely correct.

The Solution:

There is a simple solution to this problem. This can be solved easily by editing the Varien.php in Magento directory.

1. Inside your root server folder, find your root Magento directory. Navigate to the path highlighted below-


2. Locate and open the Varien.php file into a text editor of your choice (I use Notepad++).

3. Inside the Varien.php file, find 'cookieParams' by pressing ctrl+F.

4. Comment out the following piece of code colored green.

5. Now go back to your admin panel log in page and enter your correct username and password. Your username and password combination should work now and admin dashboard should appear.

I have tested this solution for Magento installation Version 1.9.2 and XAMPP installation version 5.6.3.

How to reset password and username for Magento admin panel from phpMyAdmin XAMPP

In Magento local installation using XAMPP/WAMP, whenever we enter the wrong password, the Magento admin panel won't let us log into our application backend. The 'forgotten password' link  does not work because the application is installed locally and the local server is not capable of sending us the email message with our password. Fortunately, we have the liberty to reset forgotten password using phpMyAdmin.

Forgot Password :-

1. Firstly, Log into your phpMyAdmin dashboard. Select the 'magento' database. 

2. Click on the SQL tab on top. Enter the following line of SQL query. Enter your desired new password and your current username in place of  'PASSWORD' and 'USERNAME'. Please note that you need to know your correct username for this.  

UPDATE `admin_user` SET `password` = MD5('PASSWORD') WHERE `username` = 'USERNAME';

Hit Go.

3. By following the above method we are directly manipulating the password field in the MySQL database of Magento. We are making changes in the 'admin_user' table. Please note that this will work only when the default function used by Magento framework for password encryption hasn't been tweaked with. The default function is md5. If you haven't touched the settings for changing it, this solution will work for you.  

4. Try logging in with your new password to Magento admin panel. It should work now. 

Forgot Username :-

The procedure for resetting or changing the username is same as changing the password except for the SQL query part. In this case run this query with your password as it is and new username.

I have tested this solution for Magento installation Version 1.9.2 and XAMPP installation version 5.6.3.