title: How to utilize loginbyid from outside Magento?
body: <p>I was able to utilize the login function of magento from an external site outside magento. But it works only if I have username and password. 
  There are cases where I only have the userid. I tried loginbyid, it return true and loads the customer details but once the html is loaded into the browser, it erases the customer session.
  Note that is is not the typical question "login as customer from admin" but login customer from outside using ID.</p>
  
  <pre><code>    require_once('path/to/Mage.php');
      umask(0);
      Mage::app('default','store', $options=null);
      Mage::getSingleton('core/session', array('name'=&gt;'frontend'));
      $session = Mage::getSingleton('customer/session');
      $customer = $session-&gt;getCustomer();
  
      if($session-&gt;loginById($usernameOrId)){
          $session-&gt;setCustomerAsLoggedIn($customer);
          return $session-&gt;isLoggedIn();
      }
      return false;
  </code></pre>
  
  <p>This returns true but after the page is loaded, this will now return false:</p>
  
  <pre><code>    require_once('path/to/Mage.php');
      umask(0);
      Mage::app('default','store', $options=null);
      Mage::getSingleton('core/session', array('name'=&gt;'frontend'));
      $session = Mage::getSingleton('customer/session');
      return $session-&gt;isLoggedIn();
  </code></pre>
  
  <p>Thank you.</p>