I'm trying to migrate a Webshop to a new Webserver. It is working perfectly fine on the old Webserver, however, when I try to login at the Webshop (index.html) it returns to the homepage, not logged in as the Session Variable is empty. Then I noticed, when I opened another Site called request.php) the Session Variable was set and I was logged in. So I tried several things, I renamed the index.html to index.php and the session was there.
My question is now: Can I get the Session in .html files, too (as on the previous Webserver) or do I have to rename all my .html files?
Note: The index.html file contains php code as well and is parsed as php, just the session variable is empty.
Thanks in advance for every answer!Answer1:
if you are using a Apache Server, try add this to the config file.
AddType application/x-httpd-php .htmlAnswer2:
You need to set a handler in your web server to treat
html files as
The files need to be renamed to have a .php extension on them, even if they include html. Simply include your php code before the html starts, like so:
<?php //code goes here ?> <html> <body> //etc...
This way, you can load up your session variable and any other PHP variables you need, then they'll be accessible in the html as well.
If you have several pages that will need the same thing (session variable), you could put the session code into a php file, something like 'session.php'. Then, at the top of every page you're converting from html to php, put this code at the top:
<?php require_once("session.php"); ?>
Now all of your pages will have access to the same information, and it helps to cut down on the code too.Answer4:
AddType application/x-httpd-php .html
In your .htaccess file will do the job, still I believe it's rather <strong>unsafe</strong> to do it :)