Session Variables Not Being Preserved
Posted: Thu Mar 19, 2009 1:43 pm
I am unable to use session variables on a page other than the one where they are set, IOW they act like non-session variables. I have found a similar question posted in half a dozen other similar fora, but the answer in those other cases always turns out not to apply.
Here are my files:
sess1.php
and,
sess2.php
The browser output in each case is:
sess1.php
and,
sess2.php
A few things it is NOT:
Thanks so much.
Here are my files:
sess1.php
Code: Select all
<?php
session_start();
session_register("userid");
session_register("textvar");
$_SESSION['userid'] = 10333 ;
$_SESSION['textvar'] = TextVariable ;
echo "<p>User ID is: " . $_SESSION['userid'] . "</p>" ;
echo "<p>Another variable is: " . $_SESSION['textvar'] . "</p>" ;
?>
<p>Go to the <a href="sess2.php">next page</a>.</p>sess2.php
Code: Select all
<?php
session_start();
echo "<p>The userid session variable is: " . $_SESSION['userid'] . "</p>";
echo "<p>The other session variable is: " . $_SESSION['newvar']. "</p> ";
?>sess1.php
Code: Select all
User ID is: 10333
Another variable is: TextVariable
Go to the [next page].
sess2.php
Code: Select all
The userid session variable is:
The other session variable is:
Go to the [last page].- I do have session_start() at the top of both files.
- The variables directory is writable, and the session variables are showing up there. (I have about a hundred little files called sess_b62<snip>, that have this inside: 'userid|i:10333;textvar|s:12:"TextVariable";'.)
- phpinfo() tells me that the php.ini file is being read correctly and the lifetime is set to the default, 0, i.e. until the browser is closed.
Thanks so much.