Magento – how to check the customer is logged in or not on server level

customercustomer-sessionmagento-1.9session

What i am trying to achieve is: Abandoned Customer Email Notification using 2 ways.
1). when customer logged out or closed his browser,
2). After X no. of days

ON Both ways cron will work.

For 2nd Way i have the solution.

But for the 1st way i am not getting how to check the customer is logged out or not, on the external php page or in module.

Kindly suggest, Please.

Best Answer

I found this answer on stackoverflow...

https://stackoverflow.com/questions/13723166/magento-can-not-detect-if-customer-is-logged-in-or-not

require_once 'app/Mage.php';


umask(0);

Mage::app('default');

Mage::getSingleton('core/session', array('name' => 'frontend'));

$sessionCustomer = Mage::getSingleton("customer/session");

if($sessionCustomer->isLoggedIn()) {
  echo "Logged";
} else {
   echo "Not Logged";
}

for more details check here Magento Customer login

Related Topic