I have a CMS page that only shows information when the customer is logged in. In this page I load a CMS block with this code:

{{block type="core/template" template="class_management/source.phtml"}}

In the beginning of the phtml file, to check if the customer is logged in or not, I use this:

   //display content

The problem is, if the customer loads this page not logged in, the page will not show the content. If the customer log in and go back to the page, it will still not show the content until I refresh the cache.

Is there anyway to fix this?

I am using Magento and my server has redis cache enabled.

Thank you!


You need to set cache lifetime to 0 for your custom block in your layout xml.

Inside your theme, in local.xml file, inside node add the code above:

    <block type="core/template" name="class_management_source" template="class_management/source.phtml">
        <action method="setCacheLifetime"><lifetime>1</lifetime></action>

In your CMS block you need to replace your block call with:

{{block type="core/template" name="class_management_source" template="class_management/source.phtml"}}

Don't forget to clear your Magento Cache: System > Cache Magento > Flush Magento Cache

  • Thanks for the help Jonathan, but I am not sure how to do that. I have a CMS Page that loads a CMS Block and this block is calling a phtml file. I didn't see an option to update the block layout with your code. Do I do that in the Magento Admin panel? I tried to update the CMS Page layout with this code, but didn't work... – Bruno Monteiro Feb 13 '17 at 21:40
  • Can you please show the code where you call the phtml file? – Jonathan Ribas Feb 13 '17 at 21:44
  • Sure, just updated the question with it: {{block type="core/template" template="class_management/source.phtml"}} – Bruno Monteiro Feb 13 '17 at 21:50
  • Would that be in my local.xml inside my theme folder? I tried that but still not working... – Bruno Monteiro Feb 13 '17 at 22:58
  • For the local.xml, where do I put the code? You said inside node, but I didn't get that... – Bruno Monteiro Feb 14 '17 at 19:30

Amm not sure but you can try below code, first flush the cache and check the things

{{block type="core/template" template="class_management/source.phtml" block_id="my-block" cache_lifetime=0 cache_tags="CACHE_TAG_MY_BLOCK" cache_key="my-block"}}
  • Thanks, I will try that! What is "CACHE_TAG_MY_BLOCK" supposed to be? My block ID? – Bruno Monteiro Feb 14 '17 at 17:54
  • I tried without the "CACHE_TAG_MY_BLOCK" and didn't work... – Bruno Monteiro Feb 14 '17 at 21:31

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.