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

by mageefy on Apr 12, 2023 Celebrities 363 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: 17190
Publishing
Articles: 79,741
Categories: 202
Online
Active Users: 824
Members: 4
Guests: 820
Bots: 2759
Visits last 24h (live): 5810
Visits last 24h (bots): 29395

Latest Comments

Expect complete satisfaction always. An Escort Service In Dhaula Kuan fixes what other agencies ruin. Our verified companions deliver physical pleasure worth every moan. Trustworthy service,...
While reaching mobile users is essential, hiring an agency to build a native Android app isn't an automatic win for every business. The article overlooks the heavy ongoing costs of device...
This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..  zonahoki28    
Bài viết cung cấp góc nhìn đáng chú ý về việc triển khai các chương trình phúc lợi xã hội của Chandrababu Naidu. Những chính sách hướng đến cải thiện đời sống người dân luôn là chủ đề đáng quan...
Bài viết mang đến góc nhìn đáng chú ý về việc triển khai các chương trình phúc lợi và tác động của chúng đối với cộng đồng. Mình nghĩ những chính sách hướng đến cải thiện đời sống người dân luôn...
What a blog. Lovely stuff.
on Oct 11, 2026 about The Latest Online Business
What a blog. Lovely stuff.
on Oct 11, 2026 about The Latest Online Business
Bài viết mang đến góc nhìn thú vị về các chương trình phúc lợi của Chandrababu Naidu và những tác động đối với đời sống người dân. Mình đánh giá cao những chính sách hướng đến cải thiện giáo dục,...
An unexpected evening spent with a Bhopal Escorts Service revealed new facets of desire. The atmosphere was relaxed, while the physical connection deepened with every passing moment. Soft...
We believe comfort is the gateway to real excitement. An Okhla Escort Service offers companions who prioritize your happiness. Our team creates space for fantasy to unfold and pleasure to...

Translate To: