I made this test script to pass the session variables var_one and var_two to a linked page but it just doesn't work. I made a directory on my site's hosted server that is confirmed writable just in case their tmp is not.
Session Test Page One
<?
ini_set(session.save_path, '/path/to/a/writable/directory');
if(session_start()) {
$_SESSION['var_one'] = "This is var_one";
$_SESSION['var_two'] = "This is var_two";
print_r($_SESSION['var_one']);
echo "<br>";
print_r($_SESSION['var_two']);
echo "<br>";
echo "<a href=\"session_test_two.php\">click</a>";
} else {
echo "Still not working";
}
?>
The output is as expected, both var_one and var_two are printed on the page.
Session Test Page Two
<?
ini_set(session.save_path, '/path/to/a/writable/directory');
if(session_start()) {
echo "Variable One: ";
print_r($_COOKIE['var_one']);
echo "<br>";
echo "Variable Two: ";
print_r($_SESSION['var_two']);
echo "<br>";
} else {
print "session missing!";
exit;
}
?>
Here, only the echo statements are on the page, not the session variables. I wanted to test if $SESSION or $COOKIE made a difference but apparently not. What am I doing wrong?