I am building a website where a user logs on from the index.html page. When the user logs on a php $_SESSION['username'] variable is created and then the site redirects the user to a members.php page. If the user returns to the index.html how do I check if the $_SESSION['username'] variable has already been created so the site will redirect the user back to the members.php page.
You cannot access/use any PHP code in a HTML file. What you need to do is rename index.html to index.php, from there you can use PHP code. The server will still recognize index.php as the default page of your site.
that's wrong. sure you can access PHP variables in HTML. you just need to configure your webserver to send HTML files through PHP as well. then you can for example do <?php if (isset($_SESSION["xyz"])) { // do something header("Location: /members.php"); } else { // do something else - or not } ?> <html> ..some HTML... ..some more HTML </html> be aware that the 301 redirection has to happen before any HTML is echoed, otherwise you'll get a PHP error saying "headers already sent".
Thanks for all the good advice! just for future reference, is there any way to access php variables through javascript?