Search This Blog

Tuesday, 4 December 2012

PHP: Find secure connection

<?php
$secure_connection = false;
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
    || $_SERVER['SERVER_PORT'] == 443) {

    $secure_connection = true;
}
?>

<?php if($secure_connection): ?>
  // Secure content goes here...
<?php else: ?>
  // Unsecure content goes here...
<?php endif; ?>

No comments:

Post a Comment