0
我能够从magento外部的外部站点使用magento的登录功能。但它只有当我有用户名和密码时才有效。 有些情况下我只有用户名。我尝试了loginbyid,它返回true并加载客户详细信息,但是一旦将html加载到浏览器中,它就会清除客户会话。 请注意,这不是典型的问题“从管理员登录为客户”,而是使用ID从外部登录客户。如何从Magento外部使用loginbyid?
require_once('path/to/Mage.php');
umask(0);
Mage::app('default','store', $options=null);
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
$customer = $session->getCustomer();
if($session->loginById($usernameOrId)){
$session->setCustomerAsLoggedIn($customer);
return $session->isLoggedIn();
}
return false;
这将返回true,但在页面加载后,它将会返回false:
require_once('path/to/Mage.php');
umask(0);
Mage::app('default','store', $options=null);
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
return $session->isLoggedIn();
谢谢。