I would like to do a check to know if the user is logged in, I am trying to pass this to an ajax request, but I am not succeeding.
PHP function that checks whether it is logged in
public function verificalogin(){
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$sessionCustomer = Mage::getSingleton("customer/session");
if($sessionCustomer->isLoggedIn()) {
echo json_encode('retorno' => true);
} else {
echo json_encode('retorno' => false);
}
}
Ajax
function verificalogin(data){
$j.ajax({
url: 'verificalogin.php',
type: 'POST',
data:{"retorno" : retorno},
success: function(data){
data = $j.parseJSON(data);
if (data == true ) {
console.log('Logado');
} else {
console.log('Deslogado');
}
}
})
};