0

I have ultimo theme on magento 2.3.3 with redis and varnish. After Sign Out the link still displays Sign Out and vice versa. Becomes normal after cache is flushed. looks like cache issue. Any help highly appreciated.

4
+25

Please try the following way using knockout js.
you can add following code in your .phtml file, this will help you to resolve login issue while the cache is enabled

<ul data-bind="scope: 'customer'" class="header links">
    <!-- ko if: customer().firstname -->
        <li><a href="<?= $this->getUrl('customer/account'); ?>">My account</a></li>
        <li><a href="<?= $this->getUrl('customer/account/logout'); ?>">Log out</a></li>
    <!-- /ko -->
    <!-- ko ifnot: customer().firstname -->
        <li><a href="<?= $this->getUrl('customer/account/create'); ?>">Create an account</a></li>
        <li class="authorization-link"><a href="<?= $this->getUrl('customer/account/login/'); ?>">Sign in</a></li>
    <!-- /ko -->
</ul>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "customer": {
                        "component": "Magento_Customer/js/view/customer"
                    }
                }
            }
        }
    }
</script>

Please check and let me know in case of any issue.

| improve this answer | |
  • I don't want to add any additional code. Ultimo theme does what it is supposed to. I believe it is a configuration issue. Because things become alright when I flush cache. – Zoya Dec 16 '19 at 15:36
  • @Zoya can you please share your code? – Aasim Goriya Dec 17 '19 at 8:53
1

The FPC system relies on sections.xml files that defines when some data in Magento can be renewed.

For instance, if you open the file vendor/magento/module-customer/etc/frontend/sections.xml, you will see many action paths that tell magento to renew the section data.

Now, I don't know your theme, but it may be possible the theme uses a different url end point to login/logout your customer and this path would need to be added in a sections.xml file in a custom module your would need to create

| improve this answer | |
  • Thanks. Where can I see the action names please in Ultimo theme? Is there any keyword I can grep for? – Zoya Dec 18 '19 at 17:44
  • Open your browser console, check preserve logs and clear the logs in the console. Then hit the login widget in the theme and find the call in the network tab from your developer tools (in chrome that is) – Herve Tribouilloy Dec 19 '19 at 7:41
-2

Can you please use Magento\Customer\Model\SessionFactory instead of Magento\Customer\Model\Session

$customerSes = $this->sessionFactory->create();
if ($customerSession->isLoggedIn()) {

}
| improve this answer | |
  • Which file do i modify? I am using Ultimo theme – Zoya Dec 19 '19 at 9:44
  • Sign Out and Sign In link is working on based on isLoggedIn function, so can you please check file location and check isLoggedIn function object and change object class. – Niranjan Gondaliya Dec 19 '19 at 9:49
  • Have you implement my suggestion ?? – Niranjan Gondaliya Dec 20 '19 at 6:24

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.