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.

9 thoughts on “Magento Admin not working in localhost

  1. Magento Themes

    I myself have faced that problem a couple of times, every time I search for a Magento Programmer. This is a great help for folks like me. Nice problem choice and solution.

  2. Raphael Martignoni

    It didn’t work for me. I don’t know what else I can do to make this work.

  3. Kostas

    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” !!!

  4. pramod

    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 *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">