Magento 1.9 – How to Logout Customer

logoutmagento-1.9

I am trying to logout user

I used following code

<?php
require_once 'app/Mage.php';
Mage::app();
Mage::getSingleton('customer/session')->logout();
?>

But it's not working

Please help me to solve this.

Best Answer

Jatin,you have do some mistakes.

  • First,need to set Current store for which you want to set session logout.so Change Mage::app(); to Mage::app('default'); // assume that you have only one store
  • Second,you need to add Mage::getSingleton("core/session", array("name" => "frontend")); code after Mage::app(); for inlize session for the file logout.php
  • Also ,you need to carry session to logout.php
Related Topic