I had to come up with a way to check if PHP is running in SSL mode today. This will work on both Apache, Nginx and IIS
1 2 3 4 5 6 7 8 9 10 11 12 | function is_ssl() { $secure_connection = false; if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $secure_connection = true; } return $secure_connection; } |
I found this little nifty function on StackOverflow
Post a comment
Hello guest, care to post a comment?