Check condition for login-logout in magento

Check condition for login-logout in magento

This is very simple login and logout condition in magento. Just understand this code. First if condition for login area
And else condition for logout area.

<?php if (! Mage::getSingleton('customer/session')->isLoggedIn()): ?>
<a href="<?php echo Mage::helper('customer')->getLoginUrl(); ?>"><?php echo $this->__('Login') ?></a>
// this is login area. you can add you custom code with alter anchor link.
<?php else: ?>
<a href="<?php echo Mage::helper('customer')->getLogoutUrl(); ?>"><?php echo $this->__('Logout') ?></a>
// this is only logout area.
<?php endif; ?>