0
votes

I have installed Magento 1.9.x on the root directory of the server and WordPress installed under blog directory(/blog).

I need to show cart item count and my-account link(if customer is logged in Magento) on the header of the blog(WordPress).

I also tried many available solutions like access customer session outside Magento, but nothing works for me.

require_once ("/var/www/magento_pack/app/Mage.php");
umask(0);
Mage::app("default");
Mage::app()->loadArea('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
if(Mage::getSingleton('customer/session')->isLoggedIn())
  echo Mage::getSingleton('customer/session')->getId();
else
  echo 'Not logged in';
exit;

Any suggestions?

1

1 Answers

0
votes

I've tested your code and it's working perfectly, try instead of the full path using this:

<?php
require_once ("../app/Mage.php"); # this
umask(0);
Mage::app("default");
Mage::app()->loadArea('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
if(Mage::getSingleton('customer/session')->isLoggedIn())
  echo Mage::getSingleton('customer/session')->getId();
else
  echo 'Not logged in';
exit;?>