I'm having difficulty with this, So I Googled and also read here at SO. In the end, I tried 2 small excerpts from a W3 website, in 2 files Z1.php and Z2.php like this:
Z1
<?php
// Start the session
session_start();
include ('z2.php'); (I added this)
?>
<html>
<body>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
</body>
</html>
I put in the line to include Z2 - Z2 is then:
<?php
session_start(); (note: I tried with and without this)
?>
<html>
<body>
<?php
// Echo session variables that were set on previous page
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";
echo "Favorite animal is " . $_SESSION["favanimal"] . ".";
?>
</body>
</html>
I put all that into Zend, and got, as output,
Favorite color is .
Favorite animal is .
I need this to enable me to use phpqrcode, which says about calling the QR code:"WARNING! it should be FIRST and ONLY output generated by script, otherwise rest of output will land inside PNG binary, breaking it for sure" and, for sure, it does. So I thought 2 scripts would be the way to go.
I've not tried to pass variables between scripts before, so would welcome a critical eye or two on my trial attempts to understand this method and to set me on the right path.
Paul