How to Fix Magento’s Admin Login Failing (no error message) on Localhost
2013-09-15 10:01
726 查看
You want to install a new Magento instance (version 1.4.0.1 at the time of this writing) in your machine. You followed every steps from downloading up to the setting up of your admin account. Everything went fine so you assumed you’re good to go. You tried
to login using your admin account… nothing happened. You tried again… Same login screen with no error whatsoever. You wonder what went wrong. You checked the files and the database as well as clearing the cache. You even tried resetting your account’s password
found in the Magento’s admin_usertable using the MD5 function thru phpMyAdmin but to no avail. You gave up and tried to reinstall everything only to be greeted by the very same login screen after clicking the Login
button.
The real problem lies when a Magento instance is running through a localhost and tries to create a cookie, but fails to do so because it requires a domain and localhost is not a true domain (thanks
to Mohammad Abdul Momin Arju for pointing this out in his blog).
You can do a simple check to validate this by using Firefox and Firebug to check if a cookie is being generated by the Magento’s Admin Panel login page.
Magento's Admin Panel Login without a cookie being generated upon loading
At this point, we have to edit the core files without breaking the functionality behind this domain checking feature of Magento. To do this, open the following file:
Copy the Varien.php core file which can be found below:
where we assumed that your root directory is htdocs and inside it is yourmagento folder.
Paste it in the Magento ‘local’ folder which can be found below (create needed folders if it doesn’t exists) and open the file for editing:
Go to line 96 or locate the code similar below:
Replace the code found in line 96 with this one:
For Apple machines or other operating system, try what Nirav did found in hiscomment.
The purpose of this code change is to disable the Magento’s domain checking only if it is accessed via localhost and run as usual if it is being accessed thru a valid domain.
Clear your browser’s cookies to start with a clean slate then clear the Magento cache by deleting all the contents of the following folder:
Access the Magento Admin Panel login again thru localhost while your firebug’s cookie tab being on (http://localhost:8080/magento/index.php/admin/). It should display something similar to the image below indicating that a cookie with an adminhtml name has been
generated.
Magento's Admin Panel Login showing a cookie 'adminhtml' generated after loading
At this point you should be able to login now with your admin username and password using localhost as your domain.
to login using your admin account… nothing happened. You tried again… Same login screen with no error whatsoever. You wonder what went wrong. You checked the files and the database as well as clearing the cache. You even tried resetting your account’s password
found in the Magento’s admin_usertable using the MD5 function thru phpMyAdmin but to no avail. You gave up and tried to reinstall everything only to be greeted by the very same login screen after clicking the Login
button.
The real problem lies when a Magento instance is running through a localhost and tries to create a cookie, but fails to do so because it requires a domain and localhost is not a true domain (thanks
to Mohammad Abdul Momin Arju for pointing this out in his blog).
You can do a simple check to validate this by using Firefox and Firebug to check if a cookie is being generated by the Magento’s Admin Panel login page.
Magento's Admin Panel Login without a cookie being generated upon loading
At this point, we have to edit the core files without breaking the functionality behind this domain checking feature of Magento. To do this, open the following file:
Copy the Varien.php core file which can be found below:
app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
where we assumed that your root directory is htdocs and inside it is yourmagento folder.
Paste it in the Magento ‘local’ folder which can be found below (create needed folders if it doesn’t exists) and open the file for editing:
app\code\local\Mage\Core\Model\Session\Abstract\Varien.php
Go to line 96 or locate the code similar below:
if (isset($cookieParams['domain'])) { $cookieParams['domain'] = $cookie->getDomain(); }
Replace the code found in line 96 with this one:
if (isset($cookieParams['domain']) && !in_array("127.0.0.1", self::getValidatorData())) {
For Apple machines or other operating system, try what Nirav did found in hiscomment.
The purpose of this code change is to disable the Magento’s domain checking only if it is accessed via localhost and run as usual if it is being accessed thru a valid domain.
Clear your browser’s cookies to start with a clean slate then clear the Magento cache by deleting all the contents of the following folder:
var\cache
Access the Magento Admin Panel login again thru localhost while your firebug’s cookie tab being on (http://localhost:8080/magento/index.php/admin/). It should display something similar to the image below indicating that a cookie with an adminhtml name has been
generated.
Magento's Admin Panel Login showing a cookie 'adminhtml' generated after loading
At this point you should be able to login now with your admin username and password using localhost as your domain.
相关文章推荐
- How to fix the adb no permissions error on Ubuntu Lucid
- How to fix the “msvcrt-ruby18.dll is missing from your computer” error message in Ruby on Rails
- How to fix a "Duplicated Symbols" error on binary files
- Perl ERROR "Failure to create message queue, No space left on device "
- How to fix the phpmyadmin error “json extension is missing” on Ubuntu 14.04 desktop amd64?
- How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP)
- How to fix “System program problem detected” error on Ubuntu
- How to fix apt-get GPG error NO_PUBKEY Ubuntu 14
- How To Fix ‘Update Failed (Error 7)’ Issue on Chrome Windows
- How to fix “System program problem detected” error on Ubuntu
- Error connecting to server localhost on port 1527 with message Connection refused
- How to fix a "Duplicated Symbols" error on binary files
- How To Fix Error Loading RPi.GPIO Python Library On Your Brand New Raspberry Pi 2
- How to fix “The program can’t start because MSVCR110.dll is missing from your computer.” error on Windows
- Py第二十问 How to fix “ImportError: No module named …” error in Python?
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- How to solve Xentry Error 462/ No WIS/ASRA EPC shortcuts
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- PHP编译时错误解决:Don't know how to define struct flock on this system, set --enable-opcache=no
- Mysql启动报错:ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost' (10061)