Checking for Magento login on external page

Posted by LinuxGnut on Stack Overflow See other posts from Stack Overflow or by LinuxGnut
Published on 2010-04-27T19:25:07Z Indexed on 2010/04/30 3:57 UTC
Read the original article Hit count: 267

Filed under:
|
|

I'm hitting a wall here while trying to access items from Magento on an external page (same server, same domain, etc, etc). I want to see if the user is logged into Magento before showing them certain parts on the site.

Keep in mind that this code exists outside of Magento.

Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));

if (empty($session)) 
{
  $session = Mage::getSingleton("customer/session");
}

if($session->isLoggedIn()) 
  echo "hi";

$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
echo $cart;

$cart returns 0, where I definitely have products in my cart. isLoggedIn() also returns false. What am I doing wrong here? Is there an option in Magento that I need to turn on or off to be able to access this information outside of Magento?

© Stack Overflow or respective owner

Related posts about magento

Related posts about mage