I have two websites, one is made in codeigniter and second one is in magento both are in same root server.

I want to customer login into the magento website from the codeigniter website.

Using the below code login is success but when I am going on magento website it is asking to login again.

     require_once ("../app/Mage.php");
    Mage::getSingleton('core/session', array('name' => 'frontend'));
    $session = Mage::getSingleton('customer/session', array('name'=>'frontend'));

    $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId());


    $session = Mage::getSingleton('customer/session');

    if ($session->isLoggedIn()) {
       echo "success";
  • Which version of Magento?
    – B00MER
    Commented Mar 19, 2018 at 13:21
  • Magento ver. Commented Mar 19, 2018 at 13:46

1 Answer 1


If both the Magento instance and Codeigniter are not on same the same domain, the cookie domain at,

"System > Config > Web > Session Cookie Management"

Should be set to .site.com as just blank will set to the top level domain site.com without considering subdomains.

IF they are NOT on same domain, then you'll need CORS:


Take a look at the answer below for a working example, specially $session->setCustomerAsLoggedIn($customer);

  • 1
    Both the Magento and Codeigniter are on the same domain Commented Mar 19, 2018 at 14:34
  • 1
    magento website is just in a folder of same root Commented Mar 19, 2018 at 14:35
  • @MaheshKumar updated answer.
    – B00MER
    Commented Mar 19, 2018 at 15:02
  • This is not working Commented Mar 20, 2018 at 6:12
  • Can anyone tell me what is the issue in my code. Commented Mar 20, 2018 at 6:57

Your Answer

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

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