Thursday 19 January 2012

Enable cookies problem in magento login page

When I try to add products to shopping cart, I get redirected to enable-cookies CMS page. Similarly, when I try to login as customer from customer account login, I get redirected to the same (enable-cookies) page.

The enable-cookies page asks me to enable cookies in my browser. The message says “Please enable cookies in your web browser to continue“. The page describes about Cookies and shows step-by-step instruction to enable cookies in browsers like Internet Explorer, Mozilla Firefox, and Opera. :)

When I check my browser options, I see that Cookies are enabled in my browser.

Solution:

I googled the web and found two solutions. Here are they:-

1) Increase Cookie Lifetime

– Go to System –> Configuration –> General –> Web –> Session Cookie Management –> Cookie Lifetime = 5400
– By default, Cookie Lifetime = 3600. You can make it more than 5400 and try if it works.

2) Disable redirect to enable-cookies CMS page

– Go to System –> Configuration –> General –> Web –> Browser Capabilities Detection –> Redirect to CMS-page if cookies are disabled = No


The second one has helped me. After implementing the second solution, I was able to add products to shopping cart page and was also able to login as customer.






Clear cache->Check now

 Incase that problem not rectify means do this




app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

 line 77.and below lines


Do like this....

 // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath()/*,
            'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly()*/
        );

/*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();
        }

        call_user_func_array('session_set_cookie_params', $cookieParams);

        if (!empty($sessionName)) {
            $this->setSessionName($sessionName);
        }
*/

1 comment:

  1. The modification of the Varien.php file worked for me to fix a problem with samsung tab. Clients couldn't add products to cart and log in on magento using this tablet. Thanks for the tip.

    ReplyDelete