Search code examples
phpmagento

Can I check for HTTPS in Magento PHTML files?


I am installing Clicky code on a Magento website. I would like to use their HTTPS tracker only on HTTPS enabled pages of Magento. How can I do this?

I tried

<?php if($_SERVER['https'] == 'on') : ?>

but that doesn't work.

Any suggestions on identifying HTTPS pages will be of great help!

Thanks.


Solution

  • Magento actually provides a method for this for you.

    Use this to check whether you are in secure mode:

    // check to see if your store is in secure mode
    $isSecure = Mage::app()->getStore()->isCurrentlySecure();