1

I've create a login function that make the customer login by email and password and return below response

{
    "status": "success",
    "message": {
        "id": "1",
        "name": "username",
        "firstname": "firstname",
        "lastname": "lastname",
        "email": "mail@mail.com",
        "session_id": "7ead152bcd78c30b3f7415c985ab3d0b",
        "info": {
            "postcode": "1300",
            "city": "city",
            "street": "street",
            "telephone": "1234567890",
            "fax": null,
            "country": "USA",
            "region": null
        }
    }
}

So i want to get the customer data from the session id above but it's not working.

$sess = Mage::getSingleton('customer/session', array( 'value' => $sessId ));
print_r($sess);

My Questions:

1- How i can get the customer data from session id?

2- how i can logout the customer from the session id?

NB: This request from mobile app.

0

Get the customer data from session:

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    echo "<pre>";
    print_r($customer->getData());
    echo "</pre>";
}

Logout from session:

require_once 'app/Mage.php';
Mage::app('default');
Mage::getSingleton("core/session", array("name" => "frontend"));
// get login customer data
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customerData = Mage::getSingleton('customer/session')->getCustomer();
     //echo $customerData->getId();
}

//For Logout Customer
Mage::getSingleton('customer/session')->logout();

$data['responseCode']='1';
$data['msg']="Logged Out Successfully";

$data2=json_encode($data);
echo $data2;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.