skip to Main Content

Is there any ways to force a customer to log out? The use case is that after changing the customer’s group in backend, i would need to force him to log out and log back in to see the new prices for his new group. I’m not trying to log the current user out so can’t use Mage::getSingleton('customer/session')->logout()

I looked into sessions but there seems to be no way to init a session from a customer’s ID

What i tried was setting customer id directly but it doesn’t work

$session = Mage::getModel('customer/session')->loginById(1234)->logout();

2

Answers


  1. You can use Mage::getSingleton('customer/session')->logout() or redirect the customer to the below url

    /customer/account/logout/
    

    How to force magento to logout

    Login or Signup to reply.
  2. This is how you find and delete Magento 1 customer session files.

    1. Find the customer’s id via Magento Admin Panel, e.g. .../customer/edit/id/666/ => 666
    2. Connect to your server through SSH
    3. Change your current directory to MAGENTO_ROOT
    4. List session files under Magento_Root/var/session/
      (replace 666 with actual customer id)

      grep -lr ""customer_id";s:5:"666"" ./var/session/
      
    5. Delete all listed files.

    One-liner for steps 4. and 5., use with caution! (replace 666 with actual customer id):

    grep -lr ""customer_id";s:5:"666"" ./var/session/ | xargs rm
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search