I'm trying session with PHP 4.1.1 and cannot retrieve a variable registered to a session when I go to another page.
It's running on an Apache web server on an NT 4.0 box. So far, I've had no problems with any of my php pages.
Here are my two pages to test sessions:
session1.php
<?
session_start();
$test = "This is only a test of sessions";
session_register("test");
?>
<head>
<title>Untitled</title>
</head>
<body>
<?
echo "This is a session test. Answer is $test <br>";
?>
<a href="./session2.php">Continue the session test</a>
</body>
session2.php
<?
session_start();
$session = session_id();
?>
<head>
<title>Untitled</title>
</head>
<body>
<?
echo "This is a session test. Answer is $test <br>";
echo "Session id: $session";
?>
<a href="./session1.php">Go back to the start of the session test</a>
</body>
When I run session1.php I get as output in the browser:
This is a session test. Answer is This is only a test of sessions
Continue the session test
If I link over to session2.php I get:
This is a session test. Answer is
Session id: 8b5eca70027fc222dad12f0f8a807a7bGo back to the start of the session test
What gives? It has the session id, but does not retrive the variable. I'm getting no errors, and the session files look fine in c:\winnt\temp
I'd appreciate any help as I've been fooling with this for quite some time. I've developed with asp at work, and while I prefer php, sessions were a breaze.
Thanks!