Use PHP to check if page was accessed with SSL
php, ssl
Solution
You should be able to check that `$_SERVER['HTTPS']` is set, e.g.:
if (empty($_SERVER['HTTPS'])) {
header('Location: https://mywebserver.com/login.php');
exit;
}
Problem
Is there a way to check if the current page was opened with SSL? For example, I want my login page (login.php) to check if it was accessed using SSL (https://mywebserver.com/login.php). If not, redirect them to the SSL version of the page. Pretty much, I want to enfore that the user uses the page securely.