0

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 :)

1

1 Answer 1

2

you have forgot to call the sendResponse Method.

Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse(); 
1
  • @roman204...Hey thank you very much...Its working... through google I found this only and sendResponse() was missing ... thanks :)
    – MagentoBoy
    Jan 24, 2014 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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