我阅读了有关 magento 自动登录为管理员的帖子:Magento 自动登录为管理员。我试图让它与客户合作。但我无法完成它。客户似乎已登录,但在重定向到索引时,用户尚未登录。 如果您能提供任何建议,那就太好了... 谢谢你! 贝恩德
最佳答案
如果想要自动登录,请尝试下面的操作
try{
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($email); //load customer by email i
/* if customer has ,then login */
if($customer->getId()>0){
$userSession = Mage::getSingleton('customer/session');
$userSession->setCustomer($customer);
Mage::dispatchEvent('customer_login', array('customer'=>$customer));
echo "sucess";
}else{
echo 'fail';
}
}catch(Exception $e)
{
echo 'fail';
}
关于Magento 客户自动登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23285601/