<?php $email="customer email address";
$password="customer password";
$session = Mage::getSingleton('customer/session');
$message=""; //error message to add to session
try {
$session->login( $email, $password );
if ($session->getCustomer()->getIsJustConfirmed()) {
//Customer is confirmed and successfully logged in
}
} catch (Mage_Core_Exception $e) {
//error occured
switch ($e->getCode()) {
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
//email not confirmed actions here
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
//Email or password invalid actions here
$message = $e->getMessage();//echo the error message
break;
default:
$message = $e->getMessage(); //Display other error messages
}
$session->addError($message);
} catch (Exception $e) {
//login failed because of some other error.
}?>
$password="customer password";
$session = Mage::getSingleton('customer/session');
$message=""; //error message to add to session
try {
$session->login( $email, $password );
if ($session->getCustomer()->getIsJustConfirmed()) {
//Customer is confirmed and successfully logged in
}
} catch (Mage_Core_Exception $e) {
//error occured
switch ($e->getCode()) {
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
//email not confirmed actions here
break;
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
//Email or password invalid actions here
$message = $e->getMessage();//echo the error message
break;
default:
$message = $e->getMessage(); //Display other error messages
}
$session->addError($message);
} catch (Exception $e) {
//login failed because of some other error.
}?>
No comments:
Post a Comment