0

I have the following question:

I have two files: 1) localhost/myService.php and 2) localhost/myService.html . Both files start with the following:

<?php
    // Start up your PHP Session 
    session_start();
    // If the user is not logged in send him/her to the login form
    if ($_SESSION["Login"] != "YES") {
      header("Location: Develop-index.html");
    }
?>

<!DOCTYPE html>
<!--[if lt IE 8 ]><html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
....

Is there any particular reason why with an emptied cache browser the link localhost/myService.php prevents me from accessing localhost/Develop-index.html (the desired behavior) whereas the link localhost/myService.html allows me to access localhost/Develop-index.html (not the desired behavior)?

Why session works in the first (.php) and not in the second (.html) case? Isn't the session script executed on both cases? Is it maybe because of the .html or .php at the end of the files that affects the php preprocessor?

Thank you friends!

pebox11
  • 2,247
  • 3
  • 23
  • 43
  • 2
    As the extension implies .php files will be have php code inside them that gets executed server-side and returns html. html files are client side only. They're only parsed and rendered. – Andrei P. Oct 13 '14 at 17:35
  • possible duplicate of [How do I add PHP code to .html files?](http://stackoverflow.com/questions/11312316/how-do-i-add-php-code-to-html-files) – showdev Oct 13 '14 at 17:35
  • `php` code in `HTML` page doesn't work – gr3g Oct 13 '14 at 17:36
  • 1
    @gr3g Well, it works if you modify the .htaccess file, but it may not be the best idea in the world. I'm just sayian. – Andrei P. Oct 13 '14 at 17:36
  • Didn't know that. Thought php goes in .php and html in .html ... – gr3g Oct 13 '14 at 17:39
  • 1
    If you want to execute PHP functions then the file name extensoin should be .php – Divakar Gujjala Oct 13 '14 at 17:52

0 Answers0