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" );

    // Initialize Magento

    // 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'));
    echo "Logged In";
    return $session->getCustomer();
    echo "Logged out";
    $url = "http://localhost/magento/customer/account";


thanks :)


you have forgot to call the sendResponse Method.

  • @roman204...Hey thank you very much...Its working... through google I found this only and sendResponse() was missing ... thanks :) – MagentoBoy Jan 24 '14 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.