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
    Mar 19 '18 at 13:21
  • Magento ver. Mar 19 '18 at 13:46

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 Mar 19 '18 at 14:34
  • 1
    magento website is just in a folder of same root Mar 19 '18 at 14:35
  • @MaheshKumar updated answer.
    – B00MER
    Mar 19 '18 at 15:02
  • This is not working Mar 20 '18 at 6:12
  • Can anyone tell me what is the issue in my code. Mar 20 '18 at 6:57

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.