Check login status of user in joomla

Use the following script to check if the user is logged into or logged out of Joomla

 <?php
 if(JFactory::getUser()->guest) {
 //do user logged out stuff
 echo 'Login';
 }
 else {
 //do user logged in stuff
 echo 'Logout';
 }
 ?>