allanctan
Member
Posted 2 years ago #
I believe the condition to check for https is incomplete.
Here's a more complete checking
<?php
function isSSL(){
if($_SERVER['https'] == 1) /* Apache */ {
return TRUE;
} elseif ($_SERVER['https'] == 'on') /* IIS */ {
return TRUE;
} elseif ($_SERVER['SERVER_PORT'] == 443) /* others */ {
return TRUE;
} else {
return FALSE; /* just using http */
}
}
?>
Copied from
http://www.php.net/manual/en/reserved.variables.server.php
Allan
http://www.ideyatech.com
http://wordpress.org/extend/plugins/https-for-wordpress/
jeremysawesome
Member
Posted 2 years ago #
how about this:
function isSSL()
{
if(!empty($_SERVER['HTTPS']){ return true; }
else{ return false; }
}
I suppose if you really wanted to you could check the server port.
function isSSL()
{
if(!empty($_SERVER['HTTPS'])||$_SERVER['SERVER_PORT']==443)
{ return true; }
else{ return false; }
}
I always check if $_SERVER['HTTPS'] is not empty. The PHP Documentation says that $_SERVER['HTTPS'] is, "Set to a non-empty value if the script was queried through the HTTPS protocol."