2

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.

5
  • Have you check your mage.php file is called or not? you can first check using echo inside mage.php and check its call or not ? Jun 27, 2016 at 5:48
  • Jatin,where you want to call this code? and why?
    – Amit Bera
    Jun 27, 2016 at 5:49
  • I want to logout user in. <magentohost>/logout.php @AmitBera Jun 27, 2016 at 5:51
  • @Rakesh mage.php is called Jun 27, 2016 at 5:52
  • I am trying to to create login web service, I created it I got token and token secret but when I login, I am not able to get another users token and token secret that's why I want to logout manually. @AmitBera Jun 27, 2016 at 5:55

1 Answer 1

3

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

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.