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.
- 12,713
- 39
- 142
- 236
-
Make sure everything is fine with the session – ualinker Dec 13 '12 at 15:16
11 Answers
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!!!
- 35,538
- 15
- 81
- 104
- 19,076
- 4
- 30
- 42
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...
- 69
- 2
-
Pls include code examples so that the user knows what he has to delete, might have the rows with offset no way you could now for sure you are not breaking php with the above steps. – jnhghy - Alexandru Jantea Apr 03 '17 at 11:14
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
- 39
- 3
-
-
same as the most voted answer but with a format which is way worse. – jnhghy - Alexandru Jantea Apr 03 '17 at 11:15
If you cannot log in, here is what I would do:
- Set up your host file to redirect www.localhost.com to 127.0.0.1
- Delete app/etc/local.xml
- Re-install Magento, using www.localhost.com as the URL (with skip URL validation)
- Save username and password
- Clear cookies and try again
I'm recommending number 3 as you've mentioned modifying core code (never really a good idea)
- 792
- 7
- 15
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/
- 2,837
- 3
- 14
- 28
- 1
**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.****
- 57
- 4
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
- 51
- 9
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.
- 1
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.
- 772
- 1
- 4
- 13
It's working for me.. Please follow below instruction
Goto System->Configuration->Web->Session Cookie Management
change the option 'Use HTTP only' to 'No'
- 1
- 1
- 1,449
- 15
- 24
-
-
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() ); – Randhir Yadav Jan 31 '17 at 10:37
In fact there is no programming and set up issues for this problem.
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(); }Just open another browser and open the local magento page with 127.0.0.1 instead of localhost.
- Clear the browser history with cookie for good practice.
- 1,567
- 19
- 25
- 423
- 5
- 9
