I am trying to implement a "Log In/Log Out" link like in the top menu but on a page outside of magento. Here is what I tried so far: Instead of a plain "LogIn" link I used this script to load Mage and then show the link depending on the customer being logged in or not.
<?php
require_once('tmg/app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
?>
<?php if (Mage::getSingleton('customer/session')->isLoggedIn()==0): ?>
<a href="<?php echo $this->getUrl('customer/account/login') ?>"><?php echo $this- >__('Log In') ?></a>
<?php else: ?>
<a href="<?php echo $this->getUrl('customer/account/logout') ?>"><?php echo $this->__('Log Out') ?></a>
<?php endif ?>
What is being displayed in the browser is the page up to this code and absolutely nothing after that. I also tried to put this into a test file by itself and run it but it also results in an empty browser window, no source code or anything visible. What am I doing wrong?