Rails beginner
Rails beginner

Reputation: 14514

Magento how to check if user is signed in?

How do I check if a user is signed in?

Like:

   <?php unless user_is_signed_in 
   echo "Please log in"
   end

?>

Upvotes: 0

Views: 1256

Answers (2)

Drew Hunter
Drew Hunter

Reputation: 10114

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

or

Mage::helper('customer')->isLoggedIn();

The second method calls the first - see here


So using the helper method as an example...

$isLoggedIn = Mage::helper('customer')->isLoggedIn();
if (! $isLoggedIn) {
    echo "Please log in"; 
}

Upvotes: 2

Mark
Mark

Reputation: 2473

User the customer helper:

 $this->helper('customer')->isLoggedIn()

Upvotes: 0

Related Questions