How to check customer is logged in or not in Magento


In Magento we can check that is customer logged in or not and we can get its all necessary details by its customer id too.
To get customer details we can write below code into any php or phtml file and it will load all the details of the user logged in.
So please check below code to check if customer is logged in or not :-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>How to check customer is logged in or not in Magento</title>
<!-- Create New Group and add attribute and Assign Attribute to group-->
	//Get Customer User Id
	$customer_session = Mage::getSingleton('customer/session');
	$customer_id      = $customer_session->getCustomer()->getId();