Redirect user after login
Thank you Guys.
below is the observer function that worked for me
public function setRedirectOnLogin(){
$session = Mage::getSingleton('customer/session');
if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') === false)
$session->setAfterAuthUrl(Mage::getBaseUrl());
else
$session->setAfterAuthUrl(Mage::helper('core/http')->getHttpReferer());
$session->setBeforeAuthUrl('');
}
You should first change your customer configuration:
Then use a referrer
param on the form. For instance
<form action="<?php
echo $this->getUrl(
'customer/account/loginPost',
array(
'referer' =>
// Encode the base url, or whatever URL we want to go to
Mage::helper('core')->urlEncode(Mage::getBaseUrl())
)
) ?>" method="post">
try this
<?php Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getBaseUrl()); ?>