php Magento 无法使用正确的用户名和密码登录管理员
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13860936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento can't login in admin with right username and password
提问by NewUser
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.1instead 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.
我刚刚安装Magento(1.7.0.2)在我的本地主机(LAMP)上。现在安装后,当我想去管理面板时,它要求我输入用户名和密码。虽然我使用了正确的用户名和密码,但它仍然显示Invalid User Name or Password。我清除了我的浏览器 cookie,但它再次向我显示了与登录相同的问题。我在谷歌上搜索并得到了一些我可以使用http://127.0.0.1而不是登录的东西http://localhost. 但它仍然不适合我。我已经在谷歌上搜索了一整天,正如 pe 一些博客所说,只需在 varien.php 文件中进行一些行注释,我也在 varien.php 文件中进行了注释,但仍然对我不起作用(因为这里我使用的是 1.7. 0.2 和他们在博客中讲述了 1.6.X )。我今天已经安装了 4 次 magento,但我仍然一次又一次地面临同样的问题。有人可以告诉我如何解决这个问题吗?任何帮助和建议将是非常可观的。
回答by Deepak Lamichhane
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.phpfile within your magento directory and comment those below lines
如果您无法使用正确的用户名和密码登录,这里有一些建议。如果您使用 google chrome 安装 magento,请使用 firefox 打开 magento 并编辑app/code/core/Mage/Core/Model/Session/Abstract/Varien.phpmagento 目录中的文件并在下面的行中注释
$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!!!
并使用您的凭据登录。我希望这对您有用!!!
回答by Rizwan
do these steps :
1: go through:xampp\htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\
2: open Varien.phpfile
3: make comment line number from 87 to 104save it and try to login...
做这些步骤:
1:通过:xampp\htdocs\magento\app\code\core\Mage\Core\Model\Session\Abstract\
2:打开Varien.php文件
3:将注释行号从87改为104保存并尝试登录...
回答by Chetan
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
回答by Sumit Nautiyal
**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
**正如詹姆斯所说。这种方法对我有用。这是一个更好的选择,而不是更改代码。它适用于 127.0.0.1 以及 localhost,并且在删除 app/etc/local.xml 之后。删除浏览器 cookie。在浏览器中运行 magento 的安装
localhost/magento/index.php.install.htm
本地主机/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.****
并再次设置您的用户名和密码。登录到您的管理面板。我不必删除 magento 的数据库,所以我的数据是安全的。****
回答by Checkpoint Charlie
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.
评论 cookie 参数不是正确的方法,因为将来它会被推送到服务器上并产生很多问题。我从个人经验中知道这一点。
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
最好的解决方案是将本地 url 重命名为或多或少具有典型 url 外观的形式,至少有一个点。例如:http://yoursitename.local
回答by Redwind
I agree with -Checkpoint Charlie- that commenting cookie params may cause future trouble.
我同意 -Checkpoint Charlie- 评论 cookie 参数可能会导致未来的麻烦。
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.
如果您在本地服务器上安装 magento,则必须使用 127.0.0.1/magento_install_path IP 而不是 localhost/magento_install_path 进行安装。Localhost 不接受用于 magento 安装(或类似的东西)的 cookie,这与安装时的 magento 规则有关。
回答by Wilbert van de Ridder
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.
当超过服务器上的磁盘配额时也会出现此问题,并且如果使用基于文件的 cookie 存储,则可能无法将会话信息写入磁盘。
回答by Randhir Yadav
回答by Lokesh Das
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.
从 Varien.php 中找到此代码片段并替换如下
if ((isset($cookieParams['domain'])) && !in_array("127.0.0.1", self::getValidatorData())) { $cookieParams['domain'] = $cookie->getDomain(); }只需打开另一个浏览器并使用 127.0.0.1 而不是 localhost 打开本地 magento 页面。
- 使用 cookie 清除浏览器历史记录以获得良好实践。
回答by james
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
- 设置您的主机文件以将 www.localhost.com 重定向到 127.0.0.1
- 删除 app/etc/local.xml
- 重新安装 Magento,使用 www.localhost.com 作为 URL(使用跳过 URL 验证)
- 保存用户名和密码
- 清除 cookie 并重试
I'm recommending number 3 as you've mentioned modifying core code (never really a good idea)
我推荐第 3 条,因为你提到修改核心代码(从来都不是一个好主意)


