0

I've created a website in php and I have SSL setup properly on the server. I want to make sure the session stays secure, always within HTTPS environment.
https://example.php is secure, but, I can type http://www.example.php and it loads just fine. I've tried an include file that checks for server variables:

if(isset($_SERVER['HTTPS']))
 {
    if ($_SERVER["HTTPS"] == "on")
     { 
        do something;
     }
else
  {
       header("location:https://example.com/logout.php");
   }

This is not enough to keep the page from loading if I manually enter the url as http.

Will I need change every URL to begin with https or is there a simpler, more elegant solution I am not aware of?

I have tried phpinfo() in https and then in http. If I've been to https first, and then run phpinfo() under http, HTTPS is still set to on.

Preston
  • 26
  • 3

0 Answers0