In writing a test for a php script, I want to send the tested script post data and also have it receive the $_SESSION data from the sending php test script.
Peter and Burak both showed a way to send the post data in POST data to a URL in PHP One used curl and the other html5.
Using either of the two solutions, I get the $_POST data in the tested script, but not the $_SESSION data from the sending php script.
I have tried dozens of suggestions found online, but I never get the session data using those suggestions.
Help would be appreciated.
$_SESSION data is created on the server, there is no way for a client to send $_SESSION data.
The answer is simple although it may create performance issues and even clues that you would not want to give to a hacker in a production environment. I was using it for testing and debugging on a single machine.
The answer is to place a script link on the client page as follows:
<script><?php require 'scripts/clockwise_counterclockwise.js.php';?></script>
This alters the js being inserted into the client page to include server side variables. The client gets the server variables as js variables. As the js is altered by PHP before it is sent to the client it can contain whatever server side variables you want to include and can return the variables in post variables.
Whether this would be problematic in a production environment is irrelevant. Whether it is necessary for debugging is also another matter.
I was just trying to verify that a lesson sent to a particular student in a particular session was being processed and answered by the correct student and attributed to the correct student in the db during the same session.
Jim Fuqua