Magento can't login in admin with right username and password

梦想与她 提交于 2019-12-18 10:46:29

问题


I just freshly installed Magento(1.7.0.2) on my localhost(LAMP). Now after installation when I wanted to go for the admin panel it asked me for the username and password. Although I used right username and password still its showing Invalid User Name or Password. I made clear my browser cookie but again it showed me the same problem with login. I searched over google and got something that I can login using http://127.0.0.1 instead of http://localhost. But it still not working for me. I have searched over google whole day and as pe some blogs have told that just make some line comments in varien.php file, I also made comments in varien.php file but still its not working for me(as here I am using 1.7.0.2 and in blogs they have told about 1.6.X ). I have installed magento 4 times today already but still I am facing the same problem again and again. Can someone tell me how to solve this? Any help and suggestions will be really appreciable.


回答1:


If you are having trouble to get logged in with the correct username and password, here are some ideas. If you have used google chrome to install magento, use firefox to open magento and edit the app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory and comment those below lines

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

And use your credentials to log in. I hope this works for you!!!




回答2:


do these steps :
1: go through: xampp\htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\
2: open Varien.php file
3: make comment line number from 87 to 104 save it and try to login...




回答3:


     If you are suffering to get logged in with the correct username and password. replace the code with the New code 

    Original code:-
    $cookieParams = array(
                'lifetime' => $cookie->getLifetime(),
                'path'     => $cookie->getPath(),
                'domain'   => $cookie->getConfigDomain(),
                'secure'   => $cookie->isSecure(),
                 'httponly' => $cookie->getHttponly()
            );

    New Code:-
     $cookieParams = array(
                'lifetime' => $cookie->getLifetime(),
                'path'     => $cookie->getPath()
    /*,
                'domain'   => $cookie->getConfigDomain(),
                'secure'   => $cookie->isSecure(),
                 'httponly' => $cookie->getHttponly() */
            );
File Path :-app/code/core/Mage/Core/Model/Session/Abstract/Varien.php



回答4:


If you cannot log in, here is what I would do:

  1. Set up your host file to redirect www.localhost.com to 127.0.0.1
  2. Delete app/etc/local.xml
  3. Re-install Magento, using www.localhost.com as the URL (with skip URL validation)
  4. Save username and password
  5. Clear cookies and try again

I'm recommending number 3 as you've mentioned modifying core code (never really a good idea)




回答5:


**As mentioned by james. This method worked for me. This is a better option rather than changing the code. It worked for me for 127.0.0.1 as well as localhost and after deleting app/etc/local.xml. Delete the browser cookies. Run in your browser the installation of magento

localhost/magento/index.php.install.htm

and set your username & password again. Login to your admin panel. I didn't have to delete the database of magento so my data was safe.****




回答6:


It's not right way to comment cookie params cause in future it will be push on server and make many problems. I know this from personal experience.

The best solution is rename the local url into a form more or less has the appearance of a typical url, having at least a point in a row. As example: http://yoursitename.local




回答7:


I agree with -Checkpoint Charlie- that commenting cookie params may cause future trouble.

If you install magento on local server, you have to install it using the 127.0.0.1/magento_install_path IP not localhost/magento_install_path. Localhost does not accept cookies for magento installation(or something like that), it has to do with magento rules on installation.




回答8:


This issue also occurs when the disk quota is exceeded on the server and presumably the session info can not be written to disk if file-based cookie storage is used.




回答9:


It's working for me.. Please follow below instruction

Goto System->Configuration->Web->Session Cookie Management

change the option 'Use HTTP only' to 'No'




回答10:


1.Open Varien.php file Location app\code\core\Mage\Core\Model\Session\Abstract.

2.Find and comment the bellow code

if (!$cookieParams['httponly']) {
       unset($cookieParams['httponly']);
       if (!$cookieParams['secure']) {
           unset($cookieParams['secure']);
           if (!$cookieParams['domain']) {
               unset($cookieParams['domain']);
           }
       }
   }

   if (isset($cookieParams['domain'])) {
       $cookieParams['domain'] = $cookie->getDomain();
   }

Source http://infynet.wordpress.com/2013/07/17/admin-login-fail-in-magento/




回答11:


In fact there is no programming and set up issues for this problem.

  1. Find this code snipet from Varien.php and replace as below

    if ((isset($cookieParams['domain'])) && !in_array("127.0.0.1", 
          self::getValidatorData())) {
          $cookieParams['domain'] = $cookie->getDomain();
    }
    
  2. Just open another browser and open the local magento page with 127.0.0.1 instead of localhost.

  3. Clear the browser history with cookie for good practice.


来源:https://stackoverflow.com/questions/13860936/magento-cant-login-in-admin-with-right-username-and-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!