0
I would like to do a check to know if the user is logged in, I am trying to pass this on to an ajax request but am not succeeding.
PHP function that checks if you are 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');
}
}
})
};
In the file 'verificalogin.php' there is only the excerpt shown here?
– Wictor Chaves
Yes, I managed to tidy up now, I will post the code as an answer to anyone who has the same question
– Gustavo Souza