title: Redirect A Customer To A Custom Url/Page After Logging In Magento
body: <p>I have one custom page in magento.My condition is that "if user is not loggedin so before saving any changes I am redirecting user to the login page, I want to redirect the user on my custom page after logging.".
  I am using the following code its not redirecting me on my custom page after logging.</p>
  
  <pre><code>Mage::app('default');
  if( !Mage::getSingleton( 'customer/session' )-&gt;isLoggedIn() ){                  
      $session = Mage::getSingleton( 'customer/session' );
      $session-&gt;setBeforeAuthUrl('http://'.$_SERVER['HTTP_HOST'].'/custom.html');
      header("Location: /customer/account/login");    
  }
  </code></pre>
  
  <p>its redirecting me on the login page. if I use following code instead of <code>header</code> it wont redirecting me to the login page.</p>
  
  <pre><code>Mage::app()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl("customer/account/login")); 
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>Mage::app()-&gt;getFrontController()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl('customer/account'));
  </code></pre>
  
  <p>1) I am on the same domain.</p>
  
  <p>2) "System" > "Configuration" > "Customer Configuration" section "Login Options" -> "Redirect Customer to Account Dashboard after Logging" is set to No.</p>
  
  <p>I want to set the return url before redirecting to the login page. so after login it will redirect the user to the return url page. &amp; My custom page is outside of magento.</p>
  
  <p>Here is my custom page code.</p>
  
  <pre><code>$mageFilename = 'app/Mage.php';
  require_once( $mageFilename );
  umask(0);
  Mage::app();
  if( !Mage::getSingleton( 'customer/session' )-&gt;isLoggedIn() ){                  
      $session = Mage::getSingleton( 'customer/session' );
      $session-&gt;setBeforeAuthUrl('http://'.$_SERVER['HTTP_HOST'].'/full-custom.php?sid=8');
      header("Location: /customer/account/login");
      //Mage::app()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl("customer/account/login"));  
      //Mage::app()-&gt;getFrontController()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl('customer/account'));  
  }
  </code></pre>
  
  <p>Please help!!</p>