This is my observer function for customer_register_success and customer_save_after event it execute my custom url but i m getting blank session
$customerData = Mage::getSingleton('customer/session')->getCustomer();
public function doSomething($observer)
{
$AccountController = $observer->getEvent()->getAccountController();
$Customer = $observer->getEvent()->getCustomer();
$session=Mage::getSingleton('customer/session');
$session->setBeforeAuthUrl(Mage::getSingleton("mymodule/session")->getCompurl().'state_new/1');
if (!$Customer->getCustomerActivated()) {
}
else{
//$session->setCustomerAsLoggedIn($Customer);
$response1 = Mage::app()->getResponse(); // observers have event args
$dataarray = Mage::getSingleton("mymodule/session")->getData_array();
$sampleid=$dataarray['sampleid'];
$state=$dataarray['state'];
if($state==1)
{
$collection=Mage::getSingleton('mymodule/mymodule')->customisesaved($sampleid);
if($collection)
{
$url=Mage::getUrl('mymodule/mymodule/customshow');
Mage::log($url,null,"url.log");
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
Mage::app()->getResponse()->sendResponse();
exit;
}
}
}
}
Suggest me some solution.print_r($url) $url has my custom controller url but not executing it.This is my custom controller where i want to redirect and continue the process
public function customaddAction()
{
$sampleid=$this->getRequest()->getParam('sampleid');
$login_new=$this->getRequest()->getparam('state_new');
Mage::getSingleton("mymodule/session")->setData('data_array',array('sampleid'=>$sampleid,'state'=>1));
if((!Mage::helper('customer')->isLoggedIn())||(!$login_new))
{
Mage::getSingleton("mymodule/session")->setData('data_array',array('sampleid'=>$sampleid,'state'=>1));
Mage::getSingleton("mymodule/session")->setData('compurl',Mage::helper('core/url')->getCurrentUrl());
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account'));
$this->_redirect('customer/account/login');
}
if((Mage::helper('customer')->isLoggedIn())||($login_new==1))
{
Mage::getSingleton("mymodule/session")->setData('data_array',array('sampleid'=>$sampleid,'state'=>0));
$sampleid=$this->getRequest()->getParam('sampleid');
$collection=Mage::getSingleton('mymodule/mymodule')->customisesaved($sampleid);
if($collection)
{
$this->_redirect('mymodule/mymodule/customshow');
}
else{
$this->_redirectReferer();
}
}
}
Best Answer
Try below code: