Magento - Check if a User is logged in

You may want to check if a user is logged in with Magento, possibly to display a link or promotional item. Here's how to do it:

<?php
if ($this->helper('customer')->isLoggedIn()) {
    echo("Anonymous user");
}
else {
    echo("Authenticated user");
}
?>

2 comments for Magento - Check if a User is logged in

Taran's picture

I bow down humbly in the...

I bow down humbly in the presence of such gretanses.

Anonymous's picture

I don't work with that...

I don't work with that framework but I think your source code is wrong... actually you need to swap the 'echo' callings.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.