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!