Code to autologin the customer by his email address:
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail('customer@domain.com');
Mage::getSingleton('customer/session')->loginById($customer->getId());
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl())->sendResponse();
?>
I have been exploring for a little bit for any high-quality articles or blog posts on this sort of house . Exploring in Yahoo I eventually stumbled upon this web site. Reading this info So i am glad to exhibit that I’ve a very good uncanny feeling I discovered exactly what I needed. I such a lot indisputably will make certain to do not fail to remember this web site and provides it a look on a constant basis|regularly.
ReplyDeleteMagento tutorials
I am glad it helped you.
ReplyDeleteThis code is working perfect in local magento,but when i kept same file in server its not getting logged in.May i know the reason??
ReplyDeleteMake sure the store code is correct:
ReplyDeleteMage::app("default");
Here default is the store code
Thanks for your reply,I am trying this code outside of magento. Its redirecting to home page but user is not getting logged in.Is it related session ?
Deletei am calling this code from the cakePHP website but not working....
ReplyDeleteIT's woking i have created autologin.php file in the magento and call this code....
ReplyDeleteThank you