Well, I tried to hack up the last scripts to see if 3 pages will work:
finaltest1.php
PHP Code:
<?php
// finaltest1.php
error_reporting(E_ALL);
ob_start();
session_start();
$_SESSION['var1'] = 'YesPage1var';
$sessionid = session_id();
$url = "finaltest2.php?SID=$sessionid";
if(isset($_POST['redirect']) && $_POST['redirect'] == "Redirect" ) {
ob_end_clean();
header("Location: $url" );
exit;
}
echo '<h3>finaltest1.php</h3>';
echo '<p>Session contain the string: ' . $_SESSION['var1'] . '</p>';
echo "<p>Sessionid: $sessionid</p>";
echo "<p>Redirect url is: $url</p>";
echo "<p><form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
echo '<button type="submit" name="redirect">Redirect</button>';
echo '</form></p>';
ob_end_flush();
?>
finaltest2.php
PHP Code:
<?php
// finaltest2.php
error_reporting(E_ALL);
session_id(strip_tags($_GET['SID']));
session_start();
$_SESSION['var2'] = 'YesPage2var';
$sessionid = session_id();
$url = "finaltest3.php?SID=$sessionid";
if(isset($_POST['redirect']) && $_POST['redirect'] == "Redirect" ) {
ob_end_clean();
header("Location: $url" );
exit;
}
echo '<h3>finaltest2.php</h3>';
echo '<p>Sessionid transferred using GET: ' . $_GET['SID']. '</p>';
echo "<p>Sessionid is now: $sessionid</p>";
echo '<p>Did var1 transferred to Page 2? ' . $_SESSION['var1'] . '</p>';
echo '<p>Session contain the Page 1 string: ' . $_SESSION['var1'] . '</p>';
echo "<p>Sessionid: $sessionid</p>";
echo "<p>Redirect url is: $url</p>";
echo "<p><form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
echo '<button type="submit" name="redirect">Redirect</button>';
echo '</form></p>';
echo '<p><a href="finaltest1.php">Back</a></p>';
?>
finaltest3.php
PHP Code:
<?php
// finaltest3.php
error_reporting(E_ALL);
session_id(strip_tags($_GET['SID']));
session_start();
$sessionid = session_id();
echo '<h3>finaltest3.php</h3>';
echo '<p>Sessionid transferred using GET: ' . $_GET['SID']. '</p>';
echo "<p>Sessionid is now: $sessionid</p>";
echo '<p>Did the Page 1 session get transferred to Page 3? ' . $_SESSION['var1'] . '</p>';
echo '<p>Did the Page 2 session got transferred to Page 3? ' . $_SESSION['var2'] . '</p>';
echo '<p><a href="finaltest2.php">Back to Page 2</a></p>';
echo '<p><a href="finaltest1.php">Back to Start</a></p>';
?>
What I am getting is:
PHP Code:
[b]Notice[/b]: Undefined index: SID in [b]finaltest2.php[/b] on line [b]4[/b]
[b]Warning[/b]: Cannot send session cookie - headers already sent by (output started at finaltest2.php:4) in [b]finaltest2.php[/b] on line [b]5[/b]
[b]Warning[/b]: Cannot add header information - headers already sent by (output started at finaltest2.php:4) in [b]finaltest2.php[/b] on line [b]14[/b]
[b]Warning[/b]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\PHP\sessiondata) in [b]Unknown[/b] on line [b]0[/b]
Obviously, I am doing something wrong
Bookmarks