用户登陆状态判断,Magento早封装好了:
if ($this->helper('customer')->isLoggedIn()) {
// is logon
}
判断用户登陆状态是否登陆的原理是:Magento在Session中检查CustomerID是否已经设置,并且该CustomerID在数据库中是有效的。
/**
* Check customer is logged in
* @class Mage_Customer_Helper_Data
* @return bool
*/
public function isLoggedIn()
{
return Mage::getSingleton('customer/session')->isLoggedIn();
}
/**
* Checking custommer loggin status
* @class Mage_Customer_Model_Session
* @return bool
*/
public function isLoggedIn()
{
return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId());
}
相关话题:
- Magento用户登陆状态
- 判断Magento用户是否已经登陆
- Check if user is logged in Magento
- Magento Customer登陆状态判断
0 个评论
694 次阅读