session problems across pages
| From: | obsidianchrysalis | Date: | Wed, 24 Dec 2003 22:12:18 +0000 |
| Subject: | session problems across pages | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-173311@lists.php.net to get a copy of this message | ||
thanks for the help, it definitely saved my from hours of pulling at me
hairs.
however i have a new problem. i can create session variables, but i can't
access them across pages.
for example.
page2.php
Code:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "<strong>Step 2 - Register Session </strong><br />";
// Get the user's input from the form
$name = $_POST['name'];
// Register session key with the value
$_SESSION['name'] = $name;
// Display the sssion information:
?>
Welcome to my website <strong><? echo $_SESSION['name'];
?></strong>!<br />
Let's see what happens on the <a href="page3.php">next page.</a><br
/><br />
page3.php
Code:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<strong>Step 3 - test Session Part II </strong><br />
Hey <strong><? echo $_SESSION['name']; ?></strong> Everything is still
working!<br /><br />
<strong>Pick an option:</strong><br />
Let's delete this session value now. <a href="page4.php">Click
Here.</a><br
/>
Let's destroy this session. <a href="page5.php">Click Here.</a><br
/><br />
on page2.php (after the _SESSION['name'] variable is set with a form on
another page) the value of the variable comes up fine. however on page3.php,
the value is blank. any thoughts why? i tried tinkering with the php.ini
(v.4.0 on a Win98 box) but nothing changed.