I'm having a bizarre problem accessing php SESSION data from an HTML page. I have a basic login.php which I redirect to 'page1.html.' Now I have configured the .htaccess as such:
AddType application/x-httpd-php5 .html .htm
Plus, I know that my php code is working on any given HTML page.
However, if I put :
session_start();
....
if(!isset($_SESSION['username'])){
header ("Location: http://blahblahblah/Login.html");
}
inside the body of page1.html, the if statement always fires (in fact, a var_dump($_SESSION) yields "array(0) { }"
).
But, if I take the same code, put it in 'page1.php,' everything works as expected (and a var_dump($_SESSION) gives proper values).
So, is it not possible to access $_SESSION
from an HTML page the same way you would if its extension was renamed to '.php'
? Or is there something I am doing wrong here? I would rather like to keep most of my pages as '.html'
as opposed to '.php,'
as it would be an inconvenience to go back and change all the file extensions, etc.
Much appreciated,