Magento How to check if customer is logged in or not

This is Magento default feature. In you can find login or logout link.But if you want to put somewhere login/logout button then you need to check whether a user logged in or not by the code given below.

if ($this->helper(‘customer’)->isLoggedIn() ) 

echo ‘<a href=”<?php echo $this->getUrl(‘customer/account/login/’);?>”>Login</a>’;

echo ‘<a href=”<?php echo $this->getUrl(‘customer/account/logout/’);?>”>Logout</a>’;