1

Even if I'm logged out of the site, I see my information in Online customers section in Magento admin if I'm not closing the window which seems to be normal Magento flow.

How can I destroy my session completely so that when I'm logged out, website will track me as a guest user?

I've tried firing customer_logout event and cleaning frontend cache using Mage::app()->cleanCache(); but it doesn't seem to be built for this purpose.

Here is observer function

public function flushCache(Varien_Event_Observer $observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        Mage::app()->cleanCache();
        Mage::getSingleton('customer/session')->unsetAll();
    }
2
  • If you want to remove only customer data from the magento session you can try like Mage::getSingleton('customer/session')->unsetAll() ;
    – Abdul
    Commented Oct 29, 2015 at 10:53
  • @Abdul: tried it but it didn't help. Please check updated code.
    – amitshree
    Commented Oct 29, 2015 at 11:12

1 Answer 1

1

Whenever the logout() function of Mage_Customer_Model_Session called then

Magento is assign the customer as guest using $this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);

For this reason at magento,you can see *the customer as guest *. also as per as system, after fire of customer_logout event magento is set customer as guest.So if you tried to make change then that may be not reflect

protected function _logout()
{
    $this->setId(null);
    $this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    $this->getCookie()->delete($this->getSessionName());
    return $this;
}

If you want to remove those assign then just rewrite Mage_Customer_Model_Session

and remove the code:

$this->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);

rewrite class:

<?php
class  [ModuleNameSpace]_[ModuleName]_Model_Session extends Mage_Customer_Model_Session{

 protected function _logout()
    {
        $this->setId(null);
        $this->getCookie()->delete($this->getSessionName());
        return $this;
    }

}

This may be help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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