php 为什么我无法使用谷歌浏览器登录到 magento 后端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12328366/
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
Why I can not login to magento backend using google chrome
提问by Mukesh
I am using magento community edition 1.7.0.2.I am not able to login to back end of magento.I know this problem can be because of chrome not accepting cookies. But how to fix that please help. Thanks
我使用的是 magento 社区版 1.7.0.2。我无法登录到 magento 的后端。我知道这个问题可能是因为 chrome 不接受 cookie。但是如何解决这个问题,请帮忙。谢谢
采纳答案by MS111
One simple solution is to do the installation using Opera browser and use it to log in because it saves the cookies itself. It works!
一种简单的解决方案是使用 Opera 浏览器进行安装并使用它登录,因为它会自行保存 cookie。有用!
回答by Haijerome
If you enabled the https for the Magento admin panel, then make sure to set "NO" for the option "Use HTTP Only" under System->configuration->web->Session and Cookie Management."
如果您为 Magento 管理面板启用了 https,请确保在 System->configuration->web->Session and Cookie Management 下为选项“ Use HTTP Only”设置“ NO” 。
If you have access to the database then open the table "core_config_data" and search for the Path "web/cookie/cookie_httponly" and set the value to "0".
如果您有权访问数据库,则打开表“ core_config_data”并搜索路径“ web/cookie/cookie_httponly”并将值设置为“0”。
Make sure to delete the var/cache folder. Now try to login to Magento admin panel. Mostly you can now. If not post your issue in this thread.
确保删除 var/cache 文件夹。现在尝试登录 Magento 管理面板。大多数情况下你现在可以。如果没有在此线程中发布您的问题。
So this "Not able to login Magento admin panel" issue mostly relates to the Magento cookies settings. So don't get worried if you encounter this tiny issue. With the list of answers in this thread you can easily sort this out in a few minutes time.
所以这个“无法登录 Magento 管理面板”问题主要与 Magento cookie 设置有关。因此,如果您遇到这个小问题,请不要担心。使用此线程中的答案列表,您可以在几分钟内轻松解决此问题。
回答by akt
There are two solutions for this, either one will work:
有两种解决方案,任何一种都有效:
- Change the cookie lifetime configuration.Go to backend -> Sytem -> Configuration -> Web -> Session and Cookie Management Set cookie lifetime to 86400 and save it .
- 更改 cookie 生存期配置。转到后端 -> 系统 -> 配置 -> Web -> 会话和 Cookie 管理 将 cookie 生存期设置为 86400 并保存。


- Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory.
- 转到 magento 目录中的 app/code/core/Mage/Core/Model/Session/Abstract/Varien.php 文件。
Find the code:
找到代码:
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);
or
或者
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
and replace with
并替换为
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);
or
或者
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
After this save the file.
在此之后保存文件。
回答by JoenasE
This so far is the best solution rather than changing the code elsewhere http://iamtheshadowonthesun.blogspot.com/2012/10/magento-cannot-login-to-admin-panel.html
到目前为止,这是最好的解决方案,而不是更改其他地方的代码http://iamtheshadowonthesun.blogspot.com/2012/10/magento-cannot-login-to-admin-panel.html
Using phpMyAdmin, in your magento database, look for the core_config_data table and click it. Click the "Search" tab. Then on the "path" column set the operator to LIKE %...% and the Value to cookie and click the "Go" button to search.
使用 phpMyAdmin,在您的 magento 数据库中,查找 core_config_data 表并单击它。单击“搜索”选项卡。然后在“路径”列上将运算符设置为 LIKE %...% 并将值设置为 cookie,然后单击“Go”按钮进行搜索。
After searching, set the value of web/cookie/cookie_path, web/cookie/cookie_domain, web/cookie/cookie_httponly, and web/browser_capabilities/cookies to NULL
搜索后,将web/cookie/cookie_path、web/cookie/cookie_domain、web/cookie/cookie_httponly、web/browser_capabilities/cookies的值设置为NULL
回答by useless
what worked for me is what Haijerome, unfortunatelly I can't login into the backend to change the config. This is what I execute whenever I install a new fresh magento:
对我有用的是 Haijerome,不幸的是我无法登录后端更改配置。每当我安装新的 magento 时,我都会执行以下操作:
insert into core_config_data(scope, scope_id, path, value) values("default", "0", "web/cookie/cookie_httponly", "0");
then:
然后:
rm -Rf var/cache/mage--*
回答by Mihai Stancu
My problem was the fact that the server I was running was an Ubuntu fresh install with very little server maintenance configuration.
我的问题是我运行的服务器是全新安装的 Ubuntu,服务器维护配置很少。
It had not updated it's date & time and it was 3h behind.
它没有更新它的日期和时间,它落后了 3 小时。
This made cookies received by Chrome to look as if they were already expired so Chrome discarded them.
这使得 Chrome 收到的 cookie 看起来好像已经过期,因此 Chrome 丢弃了它们。
回答by Jeff
Our Chrome users were unable to add items to their cart... changing the Cookie Lifetime to the recommended 86400 fixed it.
我们的 Chrome 用户无法将商品添加到他们的购物车中……将 Cookie Lifetime 更改为推荐的 86400 修复了它。
Magento Community 1.7
Magento 社区 1.7
Thank you!
谢谢!
Jeff
杰夫
回答by dancl
the problem is that chrome isnt storing the login cookie, this can be seen by looking at the cookies in chrome | settings | content | advanced | all cookies and site data
问题是 chrome 没有存储登录 cookie,这可以通过查看 chrome 中的 cookie 来查看 | 设置 | 内容 | 先进 | 所有 cookie 和站点数据
there's probably a number of reasons why this can happen, cookie lifetime for sure is one of them..
发生这种情况的原因可能有很多,cookie 的生命周期肯定是其中之一。
personally I encountered this problem when running magento in localhost / on a virtual machine and connecting from a browser on the same machine. specifically the problem seems to be that chrome will not store cookies if the domain name is not qualified. so if your domain name is 'http://localhost/magento' or 'http://somename/magento' chrome will not store the cookie and consequently you will not be able to login
我个人在虚拟机上的 localhost / 中运行 magento 并从同一台机器上的浏览器连接时遇到了这个问题。具体来说,问题似乎是如果域名不合格,chrome 将不会存储 cookie。因此,如果您的域名是“http://localhost/magento”或“http://somename/magento”,chrome 将不会存储 cookie,因此您将无法登录
here's the fix:
这是修复:
to keep this simple i'm sticking to the example where magento is running on localhost. the same trick will work if magento is running on a vm and you're accessing from localhost, but you need to modify the hosts file on both guest os and client in such a case. (and remember that the guest ip can change so from time to time you need to update the hosts file on the host)
为了保持这个简单,我坚持使用 magento 在本地主机上运行的示例。如果 magento 在 vm 上运行并且您从 localhost 访问,则相同的技巧将起作用,但在这种情况下,您需要修改来宾操作系统和客户端上的主机文件。(请记住,guest ip 可能会更改,因此您需要不时更新主机上的 hosts 文件)
first choose your domainname. it's only in local so you dont need to register. i'm choosing 'dansmagentodev.com'. then in magento | system | web modify baseurl in both secure and unsecure to be http://dansmagentodev.com/magento/
首先选择您的域名。它只在本地,所以你不需要注册。我选择“dansmagentodev.com”。然后在 magento | 系统| web 将安全和不安全的 baseurl 修改为 http://dansmagentodev.com/magento/
next, in the same place, modify the session cookie management 'cookie domain' to be 'dansmagentodev.com'
接下来,在同一个地方,修改会话cookie管理'cookie domain'为'dansmagentodev.com'
next we need to configure your system to know that dansmagentodev.com is really localhost. we do this via the hosts file. on windows this file is in C:\Windows\System32\drivers\etc\hosts. your virus checker will probably try to stop you modifying it (for good reason, disable virus checker while you make the modification). then add the line 127.0.0.1 dansmagentodev.com
接下来我们需要配置您的系统以了解 dansmagentodev.com 确实是本地主机。我们通过主机文件来做到这一点。在 Windows 上,此文件位于 C:\Windows\System32\drivers\etc\hosts。您的病毒检查程序可能会尝试阻止您修改它(有充分的理由,请在进行修改时禁用病毒检查程序)。然后添加行 127.0.0.1 dansmagentodev.com
And now log in from chrome.
现在从 chrome 登录。
回答by Josua Marcel Chrisano
If on firefox works. Then the problem is cookies on chrome, try to clear your chrome's cookie.
如果在 Firefox 上工作。那么问题是 chrome 上的 cookie,请尝试清除 chrome 上的 cookie。

