I am sure this is something really simple but I can't figure out what's wrong.
I have set up my html, php, and js file to work together but am having trouble with setting my own session variable and checking it across files.
I have made sure that both the HTML and PHP files contain the include for my session.php file (the file just handles session_start if not already set).
To sum it up, my HTML file has a function (userSelection aka fxn1). This function passes a value to another function (showGameInfo aka fxn2), and my .js file handles fxn2. Then, fxn2 sends it to the php file which spits out the information to display. Everything works fine until I try to define my own variable. I did this inside fxn1 in the html file. Then, I tried to echo the $_SESSION['test'] value in the php file. This is the line I added to fxn1:
<?php $_SESSION['test'] = 1 ?>;
Am I missing something really simple here? My php file shows the SESSION is set. Please let me know what might be wrong.
FXN1 is in my HTML file like this:
<script>
function userSelection(val) {
<?php $_SESSION['test'] = 1; ?>
showGameInfo(val);
}
</script>
If I take out the SESSION['test'] line in the html, the php file simply says the variable test is undefined, and displays the rest as it should.
So that tells me it's wrong in the HTML somehow..but why?
Edit1: I have included session.php in my html and php file. session.php contains this:
<?php
if (!isset($_SESSION))
session_start();
?>
Is that incorrect? It's at the top of the html. And this is how it is included in the php file as well, and my php file shows isset($_SESSION) to be true, so I assume it's correct.