Magento: Redirect back to page after logged-in in Magento

by mageefy on Apr 12, 2023 Celebrities 344 Views

If you need to go back to same page once it logged in then in list page and clicked to sign in link and then you logged in it has to go back to list page its self

Magento has default setting for not to redirect account page if you logged in from default page by default it will redirect to account dash board but you need to go page to list page for that follow the below steps--

Open header.phtml add this code at top of the file

[php]

if(!Mage::helper('customer')->isLoggedIn()) {
$loginback=$this->helper('core/url')->getCurrentUrl();
$check=strstr($loginback, 'customer/account/login');
if(!strlen($check)){
Mage::getSingleton('core/session')->setLoginBackUrl($loginback);
}
}

[/php]

override app\code\core\Mage\Customer\controllers\AccountController.php to you local or custom module and add this function

[php]

public function _loginPostRedirect()
{
$session = $this->_getSession();

if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {

// Set default URL to redirect customer to
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
// Redirect customer to the last page visited after logging in
if ($session->isLoggedIn()) {
$backUrlcustom=Mage::getSingleton('core/session')->getLoginBackUrl();
if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) {
$referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
if ($referer) {
$referer = Mage::helper('core')->urlDecode($referer);
if ($this->_isUrlInternal($referer)) {
$session->setBeforeAuthUrl($referer);
}
}
} else if ($session->getAfterAuthUrl()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
} else if (strlen($backUrlcustom)) {
Mage::getSingleton('core/session')->setLoginBackUrl('');
$session->setBeforeAuthUrl($backUrlcustom);
}
} else {
$session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
}
} else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
$session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
} else {
if (!$session->getAfterAuthUrl()) {
$session->setAfterAuthUrl($session->getBeforeAuthUrl());
}
if ($session->isLoggedIn()) {
$session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
}
}
$this->_redirectUrl($session->getBeforeAuthUrl(true));
}

[/php]

Article source: https://article-realm.com/article/Arts-Entertainment/Celebrities/42138-Magento-Redirect-back-to-page-after-logged-in-in-Magento.html

Comments

No comments have been left here yet. Be the first who will do it.
Safety

captchaPlease input letters you see on the image.
Click on image to redraw.

Reviews

Guest

Overall Rating:

Most Viewed Articles

Statistics

Members
Members: 16976
Publishing
Articles: 79,235
Categories: 202
Online
Active Users: 4990
Members: 8
Guests: 4982
Bots: 29512
Visits last 24h (live): 11845
Visits last 24h (bots): 63988

Latest Comments

Opting for a Vip Escort Delhi professional is a commitment to a premium, secure, and discreet lifestyle. Their unwavering focus on your desires, set within a private and comfortable...
I really enjoyed exploring Article Realm because it covers a variety of useful topics for people interested in building an online presence. This article especially highlights how SEO, keywords,...
on Sep 1, 2026 about The Latest Online Business
I like the focus on identifying specific gains from personal content marketing because it makes the strategy feel more purposeful than simply posting regularly and hoping something sticks. In my...
I also liked the point about low-traffic websites. AI may identify behavioral patterns faster, but when the sample size is too small, the test results can still be unreliable. A tool can speed up...
The article also made me think about something that's easy to overlook: backlinks should ultimately provide value to real users. If a link has no real context and exists only to increase the...
FNAF Game is one of those games that can make even a quiet room feel terrifying. I really enjoy how the game builds tension slowly instead of relying only on sudden scares. Watching the cameras,...
Deadshot IO is a really enjoyable FPS experience for players who like fast combat and competitive gameplay.
It is the easiest and fastest way to monetize a website. All you need to do is sign up and install the plugin, after which you can decide how many ads to display and how much revenue to generate....
It is the easiest and fastest way to monetize a website. All you need to do is sign up and install the plugin, after which you can decide how many ads to display and how much revenue to generate....
It is the easiest and fastest way to monetize a website. All you need to do is sign up and install the plugin, after which you can decide how many ads to display and how much revenue to generate....

Translate To: