So I have a javascript work around for this but I would like to know what is going on so I can use the headers as it will be more reliable, right?
Page 1 is a simple page that starts a session. Page 2 then checks if a var from pg1 is set if so echo if not header(). Simple right? Well how come it doesn't work. The session works fine but if I just go directly to page 2 then all I get is a blank screen (my stupid host doesn't allow me to see errors).
Page 1-
<?php
function testses() {
session_start();
$test = "inside a fucntion";
$_SESSION[test]=$test;
}
testses();
echo "<a href=pg2.php4>click here</a>";
?>
page 2 - as I think it should be (but doesn't work)
<?php
session_start();
$test=$_SESSION[test];
if (!isset($test)) {
header("Location: http://www.someplace.com");
exit();
session_destroy();
} else {
echo "test is set for sure";
session_destroy();
}
?>
pg 2 that works
<?php
session_start();
//$test=$_SESSION[test];
if (!isset($test)) {
header("Location: http://www.someplace.com");
exit();
session_destroy();
} else {
echo "test is set for sure";
session_destroy();
}
?>
Why does the var matter?
Thanks
Tjđ