Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:39:41+00:00 2026-06-11T20:39:41+00:00

I have the need to pass a URL to Magento, where it should redirect

  • 0

I have the need to pass a URL to Magento, where it should redirect the User after completing the logout. To store it, I do the following:

$BackTo = Mage::app()->getRequest()->getParam('backto');

if(!empty($BackTo)) {
    Mage::getSingleton('core/session')->setBackTo($BackTo);
}

When needed, I retrieve the URL using Mage::getSingleton('core/session')->getBackTo(). The issue is that, while this works well on login, it doesn’t work on logout (where it’s most needed). I can store the session variable, I can also immediately retrieve it, but, when I am in logout.phtml, where the redirect JavaScript is located, such variable is set to null.

I suspect that the redirect performed by Magento upon logout has something to do with this “disappearing” session variable, but I can’t say for sure.

For completeness, here is the relevant code (there’s more code than this, but they are mainly auxiliary functions, which don’t get called on logout).

Account Controller

class MyPackage_Redirectplugin_AccountController extends Mage_Customer_AccountController {
    /**
     * @see AccountController:logoutAction()
     */
    public function logoutAction() {
        $this->_getSession()
            ->logout()
            ->setBeforeAuthUrl(Mage::getUrl());

        // Store the "back to" URL in a session variable
        $this->StoreBackToURL();

        $this->_redirect('*/*/logoutSuccess');
    }

protected function StoreBackToURL() {
    // Store the value of the "backto" argument, if it was passed
    $BackTo = Mage::app()->getRequest()->getParam('backto');

    if(!empty($BackTo)) {
        Mage::getSingleton('core/session')->setBackTo($BackTo);
        // At this point I can see the correct value stored in the session variable
    }
}

}

Logout.phtml

// The following command returns null
$redirectURL = Mage::getSingleton('core/session')->getBackTo();

Thanks in advance for the help.

Update 12/09/25 – Found a workaround

Since I couldn’t find a way to pass a session variable to the logout page opened by redirect, I chose an alternative way: I’m passing it via the URL. Specifically, I implemented a logoutAction() which calls $this->_redirect('*/*/logoutSuccess', array('myvar' => $MyValue));.

In the template, where I have to do the redirect, I simply read such parameter using Mage::helper('core')->urlDecode(Mage::app()->getRequest()->getParam('myvar'));.

I’m aware that there might have been better ways to implement the whole thing, but I needed a bug fix solution and this does the job. Thanks to all people who answered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:39:43+00:00Added an answer on June 11, 2026 at 8:39 pm

    Update 12/09/25 – Found a workaround
    This workaround has also been posted in the question itself.

    Since I couldn’t find a way to pass a session variable to the logout page opened by redirect, I chose an alternative way: I’m passing it via the URL. Specifically, I implemented a logoutAction() which calls $this->_redirect('*/*/logoutSuccess', array('myvar' => $MyValue));.

    In the template, where I have to do the redirect, I simply read such parameter using Mage::helper('core')->urlDecode(Mage::app()->getRequest()->getParam('myvar'));.

    I’m aware that there might have been better ways to implement the whole thing, but I needed a bug fix solution and this does the job. Thanks to all people who answered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a user control in which i want to pass page url to
I have a really long string that I need to pass in a URL,
I need to pass the parameters to URL.I have posed the code. How can
So I have a situation where I need to pass some parameters on url.
I have a problem now. I need to pass an transactionID and an user
I have this url which I need to pass to the browser and would
I have a get url input which I need to pass it into databse,
I have some function where I need to pass a point datatype . somefunc(United
I have a scenario like this: I need to pass @id to the stored
I have a situation where I need to pass two parameters to an action.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.