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 ));

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.

1 Answer 1


Get the customer data from session:

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

Logout from session:

require_once 'app/Mage.php';
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

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

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.