I am using codeigniter and Magento in same domain. And I have created a function in codeigniter to check the magento customer log in status. If the customer is not logged in magento then return to magento login page but it is not redirecting it and I used just php header function but I want to use magento function and as well the reason.
public function loggedIn(){
//$customerInfo = array();
$dir = $_SERVER['DOCUMENT_ROOT'];
$fullPath = $dir.'/magento/app/Mage.php';
echo $fullPath;
require_once( "$fullPath" );
umask(0);
// Initialize Magento
Mage::app();
// You have two options here,
// “frontend” for frontend session or “adminhtml” for admin session
Mage::getSingleton('core/session', array('name' => 'frontend'));
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if($session->isLoggedIn()){
echo "Logged In";
return $session->getCustomer();
}
else{
echo "Logged out";
//header('Location:http://localhost/magento/customer/account');
$url = "http://localhost/magento/customer/account";
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
}
}
thanks :)