Question

When I logged out from my website, its successfully getting logout on the current page. But, when I click any other page for example clicks on the logo to get the homepage, it still shows as logged instead of getting logged out. When I refresh the page, it's showing fine. My all cache types are enabled. Check once the screenshot.

Cache types are enabled

Steps to reproduce the issue:

  1. Open once the website Depoto
  2. Click on login/signup from header links with the provided credentials below.
  3. You can observe the account is logged in.
  4. Now, click on log out from header links. Then you observe the account is logged out.
  5. Now, click on the Logo then you will go to the homepage.
  6. Here, you see the account is still logged in.
  7. Now refresh the page by ctrl + shift + R.Then you see the account is logged out.

Website user credentials:

username: teja.bhagavan1@gmail.com
Password: Test@123
Was it helpful?

Solution

Actually this issue is related to Magento full page or block cache. But with fresh magento it should work properly so issue is related to custom module which used for customer login or session.

OTHER TIPS

It IS working propertly. It's full page cache issue. To archieve Your goal use ajax or customer sections. Example below. In etc/frontend/di.xml

<type name="Magento\Checkout\CustomerData\Cart">
       <plugin name="interceptCustomerDataCart" type="Vendor\Module\Plugin\CustomerData\Cart"/>
   </type>

In Vendor\Module\Plugin\CustomerData\Cart.php class With function

public function aroundGetSectionData(CustomerDataCart $subject,\Closure $proceed){
$data = $proceed();
$atts=['some_attr'=>'Your value'];
return array_merge($data, $atts);
}

And finally use knockout in phtml like

<!-- ko text: getCartParam('some_attr') --><!-- /ko -->
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top