1 November, 2023

Magento Admin not working in localhost

Many of us would have face the problem of login issue in magento localhost. Let me tell you how to avoid this.

Problem: After installing magento in localhost if you try to enter admin panel after logging in you will get the same login page again without  any reasons(messages).

Solution: When logging into magento admin panel it tries to validate the url whether it is a valid domain or not and if it is not a valid domain, it will erase cookies and come back to admin login page again. Obviously our url will be http://localhost/magento and it is not a valid domain. To overcome this we need to change certain code in a file called varien.php which is located in magento core folder.

Now Let’s see how to make it work by modifying the varien.php

Step 1: Copy varien.php file from app\code\core\Mage\Core\Model\Session\Abstract folder

Step2: Paste into app\code\local\Mage\Core\Model\Session\Abstract folder. Before you paste the file you need to create the folders as specified in this path such as \Mage\Core\Model\Session\Abstract.

Step3: Open varien.php in your favorite editor.

Step4: Find line no 96 and the code will be like

if (isset($cookieParams['domain'])) {

$cookieParams['domain'] = $cookie->getDomain();

 

}

and replace with
if ((isset($cookieParams['domain'])) && !in_array("127.0.0.1", self::getValidatorData())) {
$cookieParams['domain'] = $cookie->getDomain();
}

Step5: That’s it. Now you will be able to login Magento admin panel.

Note: I am using xampp and my examples are based on that. I am using magento ver 1.4.1.

Share

Alex Sam is a mobility, IoT & chat app specialist and I would like to spend most of my time in reading and analyzing the latest happenings in the technology and how they fit into our daily lives. I always endeavor to identify more ideas and concepts, and develop user-friendly apps through leveraging technology.

9 Comments

  1. Kostas Reply

    Hi everybody.
    All i know is that i’m using wamp and cause i am a fish developer thats the only thing that worked. I was looking for solution hours know!!!
    Thanks a lot “amal” !!!

  2. pramod Reply

    Hello Friends,
    Its not working for me also.But i found the problem and sorted out.
    Please follow the step:-
    1) go to root/app/code/core/Mage/Core/Model/Session/Abstract/
    2) Open the file Varien.php
    3) go to line no. 100
    4) you will get call_user_func_array(‘session_set_cookie_params’, $cookieParams);
    5) Just delete or comment this line.
    6) Now you can login into admin.

Leave a Reply

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