Can’t login into admin panel of Magento (Problem and Solution)

Hello Friends !!

Yesterday, when I was starting to work on Magento E-commerce. When I was access Magento after installation, I can’t logged in Admin section.

After long time serching and research in Magento, finally I found the solution and currently I am able to login to admin section. Today I explain you about the problem and the solution.

First of all, what is Magento ?

Magento is one of the Opensource for E-commerce Websites. Its a top level opensource in E-commerce category.

Now time to explain the problem and the solution of the problem.

Problem

While installing magento on xampp version 2.5 you have provided admin username and password. After installation finished you no longer login with your admin account.

In fact in the “Log in to Admin Panel” window whenever you provide wrong password/username combination it displays “Invalid Username or Password.” But whenever you provide correct password it does not show anything.

Though a new url like http://127.0.0.1/magento/index.php/admin/index/index/key/d135be4de664ab83db829120740e058a/

is displayed on the address bar.
Click Here for more details :
Everytime you do this you can’t log in to admin panel.

Reason of the problem

Do you know why this problem occures ? The problem occurs because magneto could not store cookies. We run it as localhost and localhost is not true domain but to store cookies we need a domain. That’s why login stops without saying any word.

Now the time comes for solutions. There are two solutions for this problem which are shown below :

Solutions

First Solution
In different forums I saw they mentioned connecting as http://localhost/magento/index.php/admin will fail but if you connect as http://127.0.0.1/magento/index.php/admin it will work. But in my case IP address in the URL did not work too.

I made it work into whenever I changed my browser. Suppose I installed magento using google chrome browser and I open admin url into my firefox window and it worked. Though in the firefox the url http://localhost/magento/index.php/admin did not work, but url http://127.0.0.1/magento/index.php/admin worked fine.

Second Solution

Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory.

Find the code:

session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);

and replace with

session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);

After this save the file. And try to login into the admin.

I think it will work now.

If you like this post or if you have any query or question then feel free to comment.

Hello Friends !!

Yesterday, when I was starting to work on Magento E-commerce. When I was access Magento after installation, I can’t logged in Admin section.

After long time serching and research in Magento, finally I found the solution and currently I am able to login to admin section. Today I explain you about the problem and the solution.

First of all, what is Magento ?

Magento is one of the Opensource for E-commerce Websites. Its a top level opensource in E-commerce category.

Now time to explain the problem and the solution of the problem.

Problem

While installing magento on xampp version 2.5 you have provided admin username and password. After installation finished you no longer login with your admin account.

In fact in the “Log in to Admin Panel” window whenever you provide wrong password/username combination it displays “Invalid Username or Password.” But whenever you provide correct password it does not show anything.

Though a new url like http://127.0.0.1/magento/index.php/admin/index/index/key/d135be4de664ab83db829120740e058a/

is displayed on the address bar.

Everytime you do this you can’t log in to admin panel.

Reason of the problem

Do you know why this problem occures ? The problem occurs because magneto could not store cookies. We run it as localhost and localhost is not true domain but to store cookies we need a domain. That’s why login stops without saying any word.

Now the time comes for solutions. There are two solutions for this problem which are shown below :

Solutions

First Solution

In different forums I saw they mentioned connecting as http://localhost/magento/index.php/admin will fail but if you connect as http://127.0.0.1/magento/index.php/admin it will work. But in my case IP address in the URL did not work too.

I made it work into whenever I changed my browser. Suppose I installed magento using google chrome browser and I open admin url into my firefox window and it worked. Though in the firefox the url http://localhost/magento/index.php/admin did not work, but url http://127.0.0.1/magento/index.php/admin worked fine.

Second Solution

Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory.

Find the code:

session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);

and replace with

session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);

After this save the file. And try to login into the admin.

I think it will work now.

If you like this post or if you have any query or question then feel free to comment.

  • Amit

    Cool, Second option helped me. Thanks!

  • Daniel

    I will give 2 Likes :)) .Great post.

  • http://www.facebook.com/milind.waghmare.75 Milind Waghmare

    Thanks. Very Simple Because of u.

  • Nikhil

    the first solution helps me a lot and is great to check out the problem and the solution is easy and simple

  • JamesD

    Just a quick update… for Magento 1.12.0.2

    Pretty much the same as the others….

    Go to location appcodecoreMageCoreModelSessionAbstractVarien.php

    Around line 85 locate the following/similar code below:

    // session cookie params
    $cookieParams = array(
    ‘lifetime’ => $cookie->getLifetime(),
    ‘path’ => $cookie->getPath(),
    ‘domain’ => $cookie->getConfigDomain(),
    ‘secure’ => $cookie->isSecure(),
    ‘httponly’ => $cookie->getHttponly()
    );

    Note: The problem for me was the ‘httponly’ property, so that’s the only one I needed commented out.

    Comment out the following: ‘domain’ (optional), ‘secure’ (optional) and ‘httponly’ (required for me – line 91) like…

    $cookieParams = array(
    ‘lifetime’ => $cookie->getLifetime(),
    ‘path’ => $cookie->getPath(),
    // ‘domain’ => $cookie->getConfigDomain(),
    // ‘secure’ => $cookie->isSecure(),
    // ‘httponly’ => $cookie->getHttponly()
    );

  • T.A

    oh man this problem make me mad. :D at last your suggested way did the solution. thanx buddy Thanx a lot.

  • masoud

    nice thanks

  • norman

    my solution: delete the cookies for the domain and it works

  • dhickey

    nice, this one worked for me.

  • Gaurav Kumar

    Thanks for your help, Now I can access my Magento admin panel due to your second solution.

  • Eva Noguerola

    Thks, I replaced the session code varien.php file and it works!!

  • Guest

    Thks, I replaced the session code varien.php file and it works!!

  • Dnz

    thanks!

  • sanjay roya

    thanks great work sir

  • http://www.webndesign.com.br sweetgunner

    Nice explanation. Thanks!

  • makesouth

    Oh ! you are great

  • CodeNinja

    thanks this works like a charm, after trying several other alternatives from other website forums … thanks a lot.

  • Björn

    Sorry this is wrong. Do not override corefiles! To solve this issue configure your Server or go to database in core_config_data and set “web/cookie/cookie_httponly” to “0”. This solves the problem if your server is not correctly configured without override the core.

  • fabio

    ótima dica, salvou meu dia.

  • http://www.facebook.com/fabiano.dasilva.16 Fabiano Pasa da Silva

    Hello. Based on the problem I solved this setting a fake domain on hosts windows file. Finally it works. Thank you for your help.

  • vipul

    I have the same problem but my site was working fine and suddenly i got problem in login in admin. So please help me out for this.
    Your solution is already done there but not working.

  • RAVI PHAD

    Thanks Admin

    Its work fine

  • DigiDestination Ltd

    You can edit it in PHPMyAdmin:

    Table: core_config_data
    Row: web/cookie/cookie_httponly

  • Arno

    Thanks, Solution #1 works fine.

  • emmanuel

    this is a great tutorial, I was not able to enter the admin of magento with Firefox to add an image to my produits.mais you with this tutorial I résussi to enter the admin of magento with Google chrome and I could see the upload tab to add product images.

    this is a great tutorial! thank you very much …..

  • Vipul Hadiya

    Great question. same problem with magento2master

  • Vipul Hadiya

    There is no such data in magento2master

  • hari

    Technically speaking its a content management system,which was originally meant for blogs which eventually received great appreciation and was further developed to suit any website. With considerably simple modifications we can efficiently build a high functioning website.