FIX
Customer cannot login to magento 1.8.1
The
issue is raising because the custom login form does not contain any
form_key and there is a form key validation happening in
loginPostAction of magento.
Here
is the solution:
1
– Go to template/customer/form/login.phtml and
template/persistent/customer/form/login.phtml and under
<ul
class="form-list">
add
the following code in the login form
<input
type="hidden" name="form_key" value="<?php
echo Mage::getSingleton('core/session')->getFormKey(); ?>"
/>
Or
<?php
echo $this->getBlockHtml('formkey'); ?>
Go
to template/customer/form/login.phtml and
template/persistent/customer/form/login.phtml and under
1
add the following code in the login form
1
getFormKey(); ?>" /> 2 – Or if you are using the login
form in several places with different template files
Copy
app/code/core/Mage/Customer/controllers/AccountController.php to
app/code/local/Mage/Customer/controllers/AccountController.php
Open
the AccountController.php that you have copied to local and add the
following code to line 139 just after the opening of
loginPostAction()
//
generate form_key if missing or invalid
<?php
if
(!($formKey = $this->getRequest()->getParam('form_key', null))
|| $formKey != Mage::getSingleton('core/session')->getFormKey()) {
$this->getRequest()->setParams(array('form_key'
=>Mage::getSingleton('core/session')->getFormKey()));
}
?>
No comments:
Post a Comment