How to remove logout page 5 seconds when logout after?please help using magento 2.2.4. thank you!

  • explain in detail what you need – Murtuza Zabuawala Jun 23 '18 at 8:30
  • i want to remove XXX.com/customer/account/logoutSuccess/ page. dont want to showing "You have signed out and will go to our homepage in 5 seconds." page. just reurl to home page.please help ,thank you @MurtuzaZabuawala – niceonelee Jun 23 '18 at 8:54

create preference of Magento\Customer\Controller\Account\Logout class

and override execute method

in the execute method you find below code


replace above code with below


Create Preference add below code in your module's di.xml


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Customer\Controller\Account\Logout" type="[Vendor]\[Module]\Controller\Account\Logout"/>

and in your [Vendor]\[Module]\Controller\Account\Logout.php file add below code

  • how to Redirect to homepage? thank you @MurtuzaZabuawala – niceonelee Jun 23 '18 at 9:06
  • @rigu , this line $resultRedirect->setPath('*/*/'); will redirect to home page – Murtuza Zabuawala Jun 23 '18 at 9:06
  • 1
    There is no need for a "preference" here. All you need is an "afterExecute" plugin and set the redirect path there. Preference, aka class rewrite, means that you take ownership of the class. This is always a last resort. – Shawn Abramson Jun 24 '18 at 5:27
  • 1
    It worked for me. Perhaps the complete answer could include how to create a preference so you would not have to look for another topic just to create the preference. It would help beginners in Magento 2. – Diego Queiroz Jun 29 '18 at 13:25
  • 1
    That worked fine for me, thank you very much. Just so others aren't making the same mistake, make sure to change the namespace at the beginning of Logout.php to [Vendor][Module]\Controlller\Account - I made that grave mistake! :) – Thomas Harding Feb 18 '19 at 18:22

It's better to create an after plugin. Like @ShawnAbramson and @ThomasHarding already said.

Create a module and in your module a file [Vendor]/[Module]/Plugin/Customer/Controller/Account/LogoutPlugin.php file add below code

Use the following code:

namespace [Vendor]\[Module]\Plugin\Customer\Controller\Account;

use Magento\Customer\Controller\Account\Logout;
use Magento\Framework\Controller\Result\Redirect;

 * (Logout)Plugin for redirecting to homepage after logout
class LogoutPlugin

   * Redirect to homepage
   * @param Logout $subject
   * @param Redirect $resultRedirect
   * @return Redirect
  public function afterExecute(Logout $subject, Redirect $resultRedirect): Redirect
    return $resultRedirect; 

In [Vendor]/[Module]/etc/frontend/di.xml add the following code:

  <type name="Magento\Customer\Controller\Account\Logout">

After you have done this replace [Vendor] & [Module] with your own module. And do a setup:di:compile to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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