Community

Problem after trying to sign into magento from drupal

I tried to execute this code from hook_user_login

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/mage1/app/Mage.php";
 

 
umask(0);
 
Mage::App('default');
 
$session = Mage::getSingleton('customer/session', array('name' => 'frontend'));
  try {
   
$session->login('alvaro@test.com', 'cec123');
  
   
$session->setCustomerAsLoggedIn($session->getCustomer());

header('Location: http://'.$_SERVER[SERVER_NAME].'/mage1/customer/account/?SID='.$session->getSessionId());
   
  } catch (
Exception $e) {
   
print_r($e);
    exit;
  }
?>

But not able to log-in to magento and it automatically logs out of Drupal.

But if i run this code separately in a simple php page it logs into magento

I user D7 and Mage 1.7

nobody click here