Thank you for your responses. I updated my PHP session code.
I have (https) -login.php which remains https, i.e. after the user logs in to the account. Now the problem is that the user who logs into the control panel clicks on the (HTTP) -about-us.php page, the session is not transmitted via HTTP, because I have session.cookie_secure = 1, due to which the user logs out system. However, when the user returns to the dashboard page, does he also go to HTTPS?
I believe that I am missing something that causes this problem. Here is my code:
This is the header file PHP require () ed to start the session, that is, on the login.php page:
session_start(); session_regenerate_id(true); if(!isset($_SESSION['CREATED'])) { $_SESSION['CREATED'] = time(); } elseif(time() - $_SESSION['CREATED'] > 300) { session_regenerate_id(true); $_SESSION['CREATED'] = time(); } if(!isset($_SESSION['loggedin'])) { $_SESSION['loggedin']=1; } if(ob_start("ob_gzhandler")){ob_start();}
This PHP header file requires () ed on each page to check if the session is running:
session_start(); $session_errors=0; if(isset($_SESSION['CREATED'])) { if(time() - $_SESSION['CREATED'] > 300) { session_regenerate_id(true); $_SESSION['CREATED'] = time(); } } elseif(!isset($_SESSION['CREATED'])){$session_errors++;} if(!isset($_SESSION['loggedin'])){$session_errors++;} if(ob_start("ob_gzhandler")){ob_start();}
Also, if used, this is the code to enable HTTPS on non-sensitive pages like about-us.php
if ($_SERVER['SERVER_PORT']!=80) { $url = "http://". $_SERVER['SERVER_NAME'] . ":80".$_SERVER['REQUEST_URI']; header("Location: $url"); }
Thanks again for the help guys daza166
daza166
source share