1

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");
    umask(0);
    Mage::app('default');
    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());

    $customer->loadByEmail($email);

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

    $session->loginById($customer->getId());
    if ($session->isLoggedIn()) {
       echo "success";
    }
  • Which version of Magento? – B00MER Mar 19 '18 at 13:21
  • Magento ver. 1.9.2.1 – Mahesh Kumar Mar 19 '18 at 13:46
0

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:


Edit

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