5

For what I can see in questions already posted, Chrome may be a bit 'fussy' when it comes to cookies and login issues in newer versions of Magento.

The problem I'm experiencing concerns secure mode and Chrome only. If https is enabled, login in the frontend is not possible. If it is disabled, login works fine.

If wrong details are entered, I get the usual error messages, so form is definitely submitting. Because of this, I don't think this is a problem with form keys.

If input details are correct, Chrome shows the login page again with no message at all.

There are no issues in Firefox and everything works as it should.

Posted questions I've read do not seem to apply to the case of HTTPS only. So I'm a bit lost.

Has anyone experienced this issue and knows how to solve it?

migrated from magento.meta.stackexchange.com Apr 18 '15 at 15:12

This question came from our discussion, support, and feature requests site for users of the Magento e-Commerce platform.

6

100% solution

The trick was to create the directory app/code/local/Mage/Customer/Model and copy the file Session.php into it. The Session.php file can be found at app/code/core/Mage/Customer/Model. Once the file is moved over, find this section:

    public function setCustomerAsLoggedIn($customer)
{
    $this->setCustomer($customer);
    $this->renewSession();
    Mage::dispatchEvent('customer_login', array('customer'=>$customer));
    return $this;
}

Comment out the $this->renewSession( ); section, so it looks like this:

    public function setCustomerAsLoggedIn($customer)
{
    $this->setCustomer($customer);
    //$this->renewSession();
    Mage::dispatchEvent('customer_login', array('customer'=>$customer));
    return $this;
}

Make sure to clear out all login cookies. I tested this on Chrome, Firefox, and IE on Windows, and Safari on iPad and everything worked like a charm.

1

Check following:


Add some breakpoints / flags / Mage::log in controller method

public function loginPostAction()
{
    if (!$this->_validateFormKey()) {
        $this->_redirect('*/*/');
        return;
    }

If your authorization stop here - something wrong with validation form key. And you will need to check your form key.


Check your settings at system / configuration / web / Session Cookie Management

If cookie_domain is not empty - try to empty it.


Open in your chrome developer bar (don't know right name) with F12 Open Resources / Cookies / Your host and try jump through pages. Will your cookie or will not change.


This can be helpful in any magento strange behaivor: disable all your 3rd party modules, set default theme, disable caching systems.

  • 1
    I've tried all the above but with no success. Debugging showed that there's not a problem with form keys (login is working in Firefox anyway). Same behaviour with default theme and no modules. The only thing I can think of is that Chrome does not show the cookie as "secure". I'm using magentocommerce.com/magento-connect/secure-frontend-cookie.html and in FIrefox the secure header is added. Cookie doesn't seem to change when navigating but deleting cookies and starting again in either http or https doesn't change anything – cortopy Apr 20 '15 at 13:38
  • I think you don't need to use 3rd party module for this, because native magento allows it. siteground.com/tutorials/magento/magento_ssl.htm – zhartaunik Apr 20 '15 at 13:52
  • Allows what? Magento does not support secure cookies natively – cortopy Apr 21 '15 at 13:17
1

I fixed this, but I do not think it is a permanent solution. Set your cookie lifetime to 0. It makes it never expire, so Chrome will not end your session.

It was very odd issue, before when I did try to login, it would show my saved items in the cart, but my user was not fully logged in - could not access "My Account."

This fix is only pertaining to the https on Chrome, as I did test the exact same install with http and it was working fine, but when I tried https on Chrome, it failed.

Hope it helps someone - this took me 8 hours to figure out!

1

Go BO->SystemConfig->Web->Session Cookie Management and set Use HTTP only to YES

  • This doesn't really solve the problem for users on the website, you can't contact every user and ask them to clear their browser cookies. – Ben Crook Mar 15 '17 at 16:30
  • Yes. It is dirty fix. – goral Mar 16 '17 at 17:44
0

After trying with the usual suspects, I realised this may be because I'm using localhost. As it turns out, Chrome even has some reported bugs about SSL and localhost.

Strangely enough changing URLs to 127.0.0.1 instead of localhost made Chrome to accept cookies for sessions

Not sure why but at least now I know there won't be issues when going into production with a proper certificate

0

Try using n98-magerun sys:check command to check if cookie domain or domain is wrongly configured.

https://github.com/netz98/n98-magerun#system-check

n98-magerun.phar sys:check

Also clear cookies could help if there are several systems like a staging system and the cookie domain was not set.

0

the solution to solve this problem with Google Chrome is to set the cookie path and cookie domain in magento configuration. In most Magento stores these two fields are empty. This gives no problem in most browsers but SSL ic with Google Chrome is giving trouble.

set the cookie path to a slash / and set the cookie domain to .yourdomain.com (with a dot in front of your domainname)

if you are using different front views with different domain names the set default to above and the individual by selecting first your front view

0

Solution 1:

Go to System->configuration->web->Session and Cookie Management

enter image description here

Change Cookie Domain to your domain name(example.com).

Now clear you magento cache and also delete all cache of your chrome and try to login again.

Solution 2: If solution1 is not working for you, you can try this one. But make sure to revert changes you did in solution1.

Add following rules in your .htaccess file. To redirect Non www url to www.

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.