Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Login / Logout PHP
 
inspirateck
Jr. Member
 
Total Posts:  4
Joined:  2009-02-12
 

I am trying to do a login and logout link in a PHTML file, but I keep getting errors.
I know there is a solid problem in how I am echoing.

Please help me step in the right direction…
THNX

<?php if(Mage::getSingleton'customer/session' )->isLoggedIn() == 0)
echo 
"<a href="<?php echo $this->getUrl('customer/account/login'?>"><?php echo $this->__('Log In') ?></a>";    
else echo 
"<a href="<?php echo $this->getUrl('customer/account/logout'?>"><?php echo $this->__('Log Out') ?></a>";
echo 
$this->getChildHtml('content'); ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
inspirateck
Jr. Member
 
Total Posts:  4
Joined:  2009-02-12
 

Here is the rewrite - figured it out.

<?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 ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top