---
title: "magento -- magento中如何判断一个用户是否已经登陆"
author: "mypages"
date: "2009-09-21T19:32:52Z"
tags: ["PHP"]
slug: "magento-magento"
draft: false
lastmod: "2009-09-21T19:32:52Z"
id: 473701
url: "https://mypages.iteye.com/blog/473701"
---

经常用的功能，比如你的促销中使用了优惠券，可是你只想让已注册用户使用，人可以使用

Mage::getSingleton( 'customer/session' )-&gt;isLoggedIn()

来判断用户是否已经登陆

&lt;?php

if(Mage::getSingleton( 'customer/session' )-&gt;isLoggedIn()) {

echo 'You must logged in to use the cupon!.';

}

?&gt;