How to Check for HTTPS in Magento phtml Files?

How to Check for HTTPS in Magento phtml Files?

Ron Peled 7:01 am

These days our eCommerce pages are littered with third party social bookmarking tools, social media tools, facebook like buttons, add this buttons, and third party marketing scripts. It is easy to lose track of the most basic aspect of your shopping carts’ security: valid HTTPS pages. Here is a quick way to isolate all of these third party utilities and simply avoid using them in the HTTPS pages:

What I have decided to do is add a simple check before we actual plant these tools inside the page, essentially check if this page is HTTPS and if YES – do not show these tools. Here is how to do so in your phtml files:

Another less safer way to handle this is by dropping the ‘http::’ portion of the URLs. Yes, I mean you start the URLs from the ‘//’ which will then render the call from HTTP or HTTPS depending on what page you are on. However, careful with this one because many third party tools do not necessarily offer the HTTPS (Secure) option of their tools.

Happy Coding!

Related Posts:

Ron Peled

About Ron Peled

Builder of things. Builder of teams. Passion: eCommerce & Marketplaces. Magento expert. CTO Mentor.