How can I pass the customer session and information from Magento to Codeigniter in same domain. In codeigniter I have created a function to check the customer session then if the customer is logged in then returning the customer information or else redirecting to magento customer login page if not.
In codeigniter Created a function as
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'));
$customer_data = Mage::getModel('customer/customer')->getCustomer();
if($session->isLoggedIn()){
echo "Logged In";
var_dump($customer_data);
}
else{
echo "Logged out";
header('Location:http://localhost/magento/customer/account');
// Mage::app()->getFrontController()->getResponse()->setRedirect("");
}
}
When customer is loggedIn in magento then it shows "Logged In" and for logged out user it is redirecting. However, it is not showing any logged in user information.
I had tried both-- getSingleton('customer/session') and getModel('customer/customer');
but it is not returning any value. And How can I use entire magento functionality in there. I am not able to use redirect function as well so just used PHP header function.
Thanks in advance