[SOLVED] Session variables do not carry to next page
Posted: Sun Dec 23, 2007 8:23 pm
These two simple scripts are for a test of session variables. I can pass variables in a form, but not using $_SESSION, even though there is a session ID. Can anyone see what is wrong? Could this be an INI setting or configuration issue?
Output of sessionTest2.php >>>>
PHPSESSID = qvhne96mabbj8re6thfmmh6ia4
session_var =
session_var (2) =
form_var = form testing
Thanks for any advice!
Code: Select all
sessionTest1.php >>>>
<?php
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing Sessions page 1</title>
</head>
<body>
<?php
$PHPSESSID = session_id();
$_SESSION['session_var'] = 'session testing';
echo "This is a test of the sessions feature.
<form action='sessionTest2.php' method='POST'>
<input type='hidden' name='form_var' value='form testing'>
<input type='hidden' name='PHPSESSID' value='$PHPSESSID'>
<input type='submit' value='go to next page'>
</form>";
?>
</body>
</html>
sessionTest2.php >>>>
<?php
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing Sessions page 2</title>
</head>
<body>
<?php
echo "PHPSESSID = {$_POST['PHPSESSID']}<br>\n";
echo "session_var = {$_SESSION['session_var']}<br>\n";
echo "session_var (2) = ".$_SESSION['session_var']."<br>\n";
echo "form_var = {$_POST['form_var']}<br>\n";
?>
</body>
</html>PHPSESSID = qvhne96mabbj8re6thfmmh6ia4
session_var =
session_var (2) =
form_var = form testing
Thanks for any advice!