Magento Forum

   
SOLVED:  Specify Login Redirect Destination
 
CVinson86
Member
 
Avatar
Total Posts:  40
Joined:  2008-06-18
 

I was just wondering if anyone knew of a way to redirect back to the page you came from after you login.  I have several custom pages that check to see if the user is logged in, and if not sends them to the login page, and I want it to redirect back to that page once they are logged in.  Any ideas?
Thanks
-Colin

 
Magento Community Magento Community
Magento Community
Magento Community
 
PandaWebStudio
Member
 
Avatar
Total Posts:  40
Joined:  2008-04-19
Amsterdam, Netherlands
 

You can add this code in your methods:

if( !Mage::getSingleton('customer/session')->getCustomerId() ) {
            Mage
::getSingleton('customer/session')->authenticate($this);
            return;
        
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jumentfolle
Member
 
Total Posts:  40
Joined:  2008-03-06
 

Hey,
is there a chance to make the same to redirect the customer to the page he came from before creating an account? Since I disabled the checkout as a guest, some of my customers are lost once they finished to create their account, and don’t know how to get back to the cart, for example…

Thanks,
Sarah

 
Magento Community Magento Community
Magento Community
Magento Community
 
melonakos
Jr. Member
 
Total Posts:  2
Joined:  2008-07-19
 

I too really need a solution to this.  If people visit my Purchase Page without logging, I provide a link for them to login.  Then after logging in, I need them to be automatically directed back to the Purchase Page.

-John

 
Magento Community Magento Community
Magento Community
Magento Community
 
CVinson86
Member
 
Avatar
Total Posts:  40
Joined:  2008-06-18
 

SOLVED:

if( !Mage::getSingleton'customer/session' )->isLoggedIn() ){  

    $session 
Mage::getSingleton'customer/session' );
    
$session->setBeforeAuthUrl('#DESTINATION URL#');
    
header("Location: customer/account/login");

     
}

Hope this helps someone.
-Colin

 
Magento Community Magento Community
Magento Community
Magento Community
 
rteague612
Member
 
Avatar
Total Posts:  48
Joined:  2008-07-29
 

where would one insert this code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
diomedes
Jr. Member
 
Total Posts:  7
Joined:  2009-04-07
 

Same question. Where can I find a script that login form is using?

rteague612 - 05 February 2009 07:50 AM

where would one insert this code?

 
Magento Community Magento Community
Magento Community
Magento Community
 
CVinson86
Member
 
Avatar
Total Posts:  40
Joined:  2008-06-18
 

In my case, I was making some custom pages that I needed to be accessible only to people who are logged in.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top