Wallpapers Forums Login

How To Detect If Url Is Secured Ssl With Php In Https

$_SERVER['HTTPS']



if you want to know if you are using a secured url using port 443 within your site, you can use $_SERVER['HTTPS'], if you are using it will display on

echo $_SERVER['HTTPS'];

this way you can check if your page is using https or http

hope that helps

here is an example of how you can use it

<?php
if($_SERVER['HTTPS']){
echo 'you are secured';
}else{
echo 'you are not secured';
}
?>

try it
web31337 Wed Apr 14, 2010
FIX:
code is
fastcgi_param HTTPS $ssl_protocol;

for some reason "param" was truncated... maybe my fault.
web31337 Wed Apr 14, 2010
This is not working by default in nginx php(fastcgi) and that code will issue notice if in max error_reporting mode.
If you want to check if it is SSL-connected you may wish to add the following line to your fastcgi params list:

[code]fastcgi_pa HTTPS $ssl_protocol;[/code]

$ssl_cipher variable instead of $ssl_protocol.
HTH.
Nate Tue Sep 08, 2009
it’s not safe to do it this way. some web servers will set $_server['https'] to 'off' when ssl is not being used. it’s better to test for $_server['https'] == 'on'.
Jeff Sat Aug 15, 2009
you can make an assumption based on your own uploads about the port number however, assuming you use the standard port 443 as your ssl port, you can check to see if $_server["server_port"] does in fact equal 443 -- which is most likely being used for ssl so it is a good backup choice
Jeff Sat Aug 15, 2009
not every apache and mod-ssl server uses this server variable, one of the ones i have access to does not have any ssl variables so detecting it is impossible on that one

Related Content

Information

Share

wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5