I made a customer log-in to the site programmatically... I am properly returned the session values in form of an object.
Now i want this data carried over and returned from the function in JSON format.
I know magento has its own encoding and decoding functions... But this conversion does not some how take place properly.
I mean session object contains customer's email, first, last name,etc. But these are not reflected in converted json... So how do I convert this properly??
Thanks in advance
Here is my code..
<?php
function loginUser( $email, $password )
{
require_once ("../../app/Mage.php");
umask(0);
ob_start();
session_start();
Mage::app('default');
Mage::getSingleton("core/session", array("name" => "frontend"));
$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();
$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId;
$customer->setStore($store);
try {
$customer->loadByEmail($email);
$session = Mage::getSingleton('customer/session');
$session->login($email, $password);
$session->setCustomerAsLoggedIn($customer);
$jsonData = Mage::helper('core')->jsonEncode($session);
var_dump($jsonData);
}catch(Exception $e){
return $e->getMessage();
}
}
$test = loginUser("[email protected]","testigex");
//var_dump($test);
?>