Magento Notes - Fix for admin login problem
Today’s Magento installation has become a real drag!! The upgrade to version 1.2.1 was troubling as after the upgrade I had trouble logging into the admin page. After digging for hours trying to find a fix, I finally came up with the right fix!! View Entire Thread Here
The long and short of the fix is that apparently the newer Magento version is implementing some security check to make sure that the domain is a valid one that is accessing the admin page; a valid domain name or host consists of one with a period in the host name, so if you are installing locally using something like http://localhost, YOU WILL RUN INTO THIS PROBLEM! There are a couple ways to fix this
1) you can reference your admin page by using http://127.0.0.1 (this way it has periods in the host name) instead of localhost or
2) if you are on windows xp, add a host record in your hosts file by going to: C:\WINDOWS\system32\drivers\etc and have 127.0.0.1 point to something like magento.localhost
3. modify the core Magento code (keep in mind you may have to re-apply the fix if you update the code Magento code) - go to: app/code/core/Mage/Core/Model/Session/Abstract and open up varien.php, and comment out lines 73 (comment out the comma at the end of the line) through 76 so that it looks like the following:
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath() //remove this after putting on server (leave the comma) ,
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);
I am sure many people will appreciate this fix!

hi thank you friend its realy helpfull for me
Thanks. Works perfect (You can change a domain - with dots - it works too).
Regards.
Glad it works.
Thank you very much!!! You have help me so much! Thanks Thanks Thanks
My pleasure
Would love to see your Magento site when you have it running. Good luck.
Does not solve the problem on my online installation.
Still locked out.
Thanks anyway.
Another solution?
Is this a local install? If so, are you able to access the admin page with the local ip of 127.0.0.1? Any error messages?
Same problem on http://www.twoedgedclothing.com/ so that can’t be explained by the lack of dots in the hostname. Just installed, everything seems fine, but admin login is being denied. I reset the password to no avail.
Do you get an “Access Denied” message? if you do, then it’s a totally different problem you are encountering. One way to reset the admin password is to re-setup the database config info (including admin login/pswd). You can do this by simply renaming the “local.xml” file under: /app/etc, and then re-run your web site. Good luck.
Your post (and link to discussion forum) was most helpful in de-stressing my afternoon… thank you!
Hopefully I can get productive once again, instead of trying to trawl through web forums looking for solutions to silly problems introduced by a simple (and recommended by the developers) upgrade.
Glad to know you find this helpful. Please come back and share your site with us when you launch
Hi,
I’ve got the same problem than Fletch (”Access Denied” when I try to log in the admin panel). I’ve tried editing the admin password or name directly in the DB, I’ve tried re-installation of the web site but nothing… Any idea?
Hi Guys. I begin with my poor english. I’m sorry. Thnks so much 4 all Jerry Lee.
So, i think i’ll learn better speak english that install or run Magento in my localhost, jiji ok anyway
i’ve re-installed Mangeto using http://127.0.0.1/ address and that it seems to work.
but when I enter in Admin Panel I get this message:
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 4864 bytes) in /var/www/app/code/core/Mage/Tag/Helper/Data.php on line 32
Cheers people
I’ve spent half an hour to check this problem. Thank you and thanks to Google to have indexed your blog post.
@Angel
the error you have posted about memory size, I’ve never encountered, but I found this posting on Magento forum…take a look and see if it helps:
http://www.magentocommerce.com/boards/viewthread/20534/
@Davi
You are very welcome. Come back and show us your Magento site when you are ready
Now for this reason i can’t access my site from any other machine.
Other machine can’t recognize my machine using the magento.localhost
Hi jerry , I am still stucking with the problem.I cant access my website
from other machine.I think it is due to change in the host file.
Can any body help me to solve this problem
Great help!! Thank you very much
You are the man… thanks bro.
Yesssssss!!!! No works under Chrome too!!! Thank youuu!!
problem solved
using http://127.0.0.1
thanks bro
this solved my problem at localhost.
Thanks man!
Great Help dude!
Thank you.
there is another possible fix which works for me, edit your hosts file, linux /etc/hosts windows its somewhere else (google it) and create a domain there like magento.dev pointing to your local IP (apache) in my case 127.0.1.1 and restart apache… obviously you will need a virtual server listening on magento.dev pointing to your development site….
Obviously the above is good if you have more than one development environment ^ you can change your magento base URL (temporarily) while you develop by going into phpmyadmin and running:
SELECT * FROM `core_config_data` WHERE `path` LIKE ‘%base_url%’;
and editing the appropriate fields….
Thanks man!
Hi,folk
This works great!!
Can anyone tell me What caused it to not work for localhost? I used 127.0.0.1 to access admin but it failed and then came to here and I scan all 3 solution posted on top of the page and picked third one.
I think, if i update my magento to latest one then I would have to re-write again. Am I right?
Thanks again
Cheers !
Web-Farmer@letsnurture.com
hey thank its really done for me.
thanks once again
Waooooooooo,
it’s very nice, thank you very much Sir,
awesome!!!
Very useful post. all magento uaers must need this.
muy bueno gracias! saludos de Peru
thanks mate! I was looking for a solution for too long. this solved the problem on my LOCAL installation!!
it doesn’t work for me on localhost. WHY??
I tried to modify Varien.php
I used http://127.0.0.1:8888/index.php/admin/
and http://127.0.0.1:8888/admin/ instead of http://localhost:8888/admin
but I can not log into the admin.
Can anybody help PLEASE!!
If the domain is not a true domain then this problem occurs. Its like if you use your localhost to run magento store,then you will face this problem.
You can overcome this by browsing using ur ip address or you can remove these three line from the following page.
app\code\core\Mage\Core\Model\Session\Abstract\varien.php
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
Comment these lines line (may be at line 78…);
Hope magento admin will work now on your localhost with the following url.
http://localhost/magento/admin/
Just try out and play with your stores……
Thanks for your tips. Really its very useful for new user
Thanks for help dude!!!
Thanks a lot bro for the help. it works for me as well…
It’s Really great tutorial.
thanks body to help us.
Regards
Ramakant
thanks…the fix really helped me a lot.
God bless.
thanks, Great technique
Adeel
Thanks for you help.its work fine
hi guys easy solution is use Opera with that its work fine. my personal experience
In the latest version of which i’m using is 1.4.0.1
in that the below mentioned code is not available
app\code\core\Mage\Core\Model\Session\Abstract\varien.php
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
Comment these lines line (may be at line 78…);
So after doing r&d i found out the solution
search for “// session cookie params” line in app\code\core\Mage\Core\Model\Session\Abstract\varien.php
change
$cookieParams = array(
‘lifetime’ => $cookie->getLifetime(),
‘path’ => $cookie->getPath(),
‘domain’ => $cookie->getConfigDomain(),
‘cookieParams’ => $cookie->isSecure(),
‘httponly’ => $cookie->getHttponly()
);
to
$cookieParams = array(
‘lifetime’ => $cookie->getLifetime(),
‘path’ => $cookie->getPath()
);
and comment the below mentioned code
line number 86, in my file
/* 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();
}
*/
now login as admin, it will work
Thnx, it works!!!
Thanks a bunch. Its now working on my website. Hopefully, now I can learn it soon and finish up a new website design in magento.
Instead commenting all those line of codes which make it pretty unsecured when used in a production environment, why not detect the domain if its localhost and disable it, then restore usual function when it’s not.
This is how I did it:
http://mysillypointofview.richardferaro.com/2010/03/24/how-to-fix-magentos-admin-login-failing-no-error-message-on-localhost/