Tag Archive: customer session


How long customer is inactive ?

$customer = Mage::getSingleton('customer/session')->getCustomer();
$log = Mage::getModel('log/customer')->load($customer->getId());
$inctive_time = now() - $log->getLastVisitAt();

Force customer login

I had a requirement like customer support will able to login as any customer. Here is the code snippet i used to force customer support to login as normal user.

  $customerId = (int) $this->getRequest()->getParam('id');
  $customer   = Mage::getModel('customer/customer')
                    ->load($customerId);

  $userSession = Mage::getSingleton('customer/session');
  $userSession->setCustomer($customer);
  Mage::dispatchEvent('customer_login', array('customer'=>$customer));

  $this->getResponse()->setRedirect(Mage::getUrl('customer/account'));