One of the problems that Magento-based online store owners may encounter is that the shopping cart may not get emptied when the customer leaves the store. So the next time the user logs back into the system, the new items get merged with the old ones.
The thing is that the default Magento Quote Lifetime settings allow only to limit the period of time a unit can remain in the shopping cart. Unfortunately, there are no settings which would clear the cart when a customer abandons the page or logs out of the store.
This may seem quite a beneficial ‘feature’ in terms of sales but still can be quite annoying for customers.
To solve this, some users create their own Magento extension which would listen for the log out event and remove all cart contents. But the problem here is that this method works only if customers manually log out, if they are logged out due to a session time out all the cart contents remain.
So one of the workarounds here would be trying not to customize the logout settings, but, instead, clear the previous items from cart when the customer logs back into the system – an observer on customer login event can do the task.