What I would like to do is share a global variable between scripts, without using a $_SESSION variable. Is this possible? My eventual goal is to assign a PDO database handle to this variable in order to be able to use it between scripts within the same application (using a $_SESSION variable causes an exception). In J2EE you would simply assign the variable to the application context.
Here is some sample code with two different scripts that is not doing what I had hoped it would.
What gets printed out is: [text]The message is: [][/text]
What I would like to have printed out is: [text]The message is: [hello world][/text]
Here is the code:
Code: Select all
<?php
// create_message.php
$hello = "hello world";
header ("Location: http://localhost/read_message.php");
exit();
?>
<?php
// read_message.php
global $hello;
echo "The message is: [$hello]";
?>