Magento中如何获取/判断用户登录状态
来源:互联网 发布:公司连锁数据销售分析 编辑:程序博客网 时间:2024/05/17 06:35
开发人员直接用
Mage::getSingleton('customer/session')->isLoggedIn()
来判断用户是否登录
比如一般magento开发人员会这样用
<?PHP//get customer login status ?><?php $myStatus = Mage::getSingleton('customer/session')->isLoggedIn() ?><?php if($myStatus): ?><li><a href="/customer/account/index" title="Customer Register">My account</a> |</li><li><?php echo $this->getLayout()->getBlock('header')->getWelcome() ?></li><?php else: ?><li><a href="/customer/account/index" title="Customer Register">My account</a></li><li><a href="/customer/account/create" title="Customer Register">Register</a></li><?php endif ?>
但其实在magento里面用户登录状态判断函数早已封装好了.
判断用户登陆状态是否登陆的原理是:Magento在Session中检查CustomerID是否已经设置,并且该CustomerID在数据库中是有效的。
在app/code/core/Mage/Customer/Helper/Data.php文件中
/** * Check customer is logged in * * @return bool */ public function isLoggedIn() { return Mage::getSingleton('customer/session')->isLoggedIn(); }
在app/code/core/Mage/Customer/Model/Session.php文件中
/** * Checking customer login status * * @return bool */ public function isLoggedIn() { return (bool)$this->getId() && (bool)$this->checkCustomerId($this->getId()); }
所以我们可以在全局用
if ($this->helper('customer')->isLoggedIn()) { // is logon }
在magento中判断用户的登录状态或是否登录
0 0
- Magento中如何获取/判断用户登录状态
- magento -- magento中如何判断一个用户是否已经登陆
- magento -- magento中如何判断一个用户是否已经登陆
- 人人网如何判断用户登录状态
- 获取Magento用户登陆状态
- Membership 获取登录状态判断是否登录用户
- Magento获取用户登录状态及登录用户信息 /页面加载 XML 文件
- Magento中如何判断一个用户是否已经登陆
- magento-怎么判断用户是否登录?
- PHP判断用户登录状态
- jsp中如何通过session判断用户是否登录?
- 如何解决每次向后台发起请求时判断用户是否处于登录状态?
- 如何在其他servlet中获取用户登录id
- php 用户登录:如何判断用户是否登录
- magento查看用户是否登录
- 点击tabbarItem的时候判断用户是否处于登录状态
- springmvc拦截器实现对用户登录状态的判断
- 如何在DotNet 2的登录组件中检索用户的锁定状态及解锁?
- Linux定时任务Crontab命令详解
- Matlab常用绘图
- (转)js如何去当前时间前一天的时间和后一天
- Paths through the Hourglass UVA
- 彻底明白IP地址——计算相关地址
- Magento中如何获取/判断用户登录状态
- Android面试题四-简答题
- 分享Kali Linux 2017年第18周镜像文件
- 5.5 JLL 实习日志
- android中绘图Paint.setAntiAlias()和Paint.setDither()方法的作用
- 7个你现在就该学习Python的理由
- VS调试技巧
- Git 快速clone到本地
- java匿名内部类