I was trying to acquire session of logged in customer in one of external PHP script in the same folder as my Magento installation:
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
$session = Mage::getSingleton('customer/session', array('name' => 'frontend'));
var_dump($session->getId());
var_dump($session->getCustomerId());
$coreSession = Mage::getSingleton('core/session', array('name' => 'frontend'));
if(isset($coreSession['visitor_data']['customer_id'])){
$customerId = $coreSession['visitor_data']['customer_id'];
} else {
die('Action not allowed. (1)');
}
Which output when accessed via the exact domain as my store:
NULL NULL Action not allowed. (1)
When I'm logged in my store frontend as a test customer.
What am I doing wrong here?