Hi, I'm having major problems getting $_SESSION variables to work on my web server. They don't keep their values. I've written some simple scripts to show the problem.
Script1 - sets the session variable
Script 1 output:
and script 2 displays the variable (it should but it doesn't)
Script2 output - the SESSION value is blank?!:
You can see my phpinfo()here (unsafe - I know):
link
I'm really pulling my hair out over this!
Cheers.
Script1 - sets the session variable
Code:
<php?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>session test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
$_SESSION['testvar']="test value";
echo "session testvar=".$_SESSION['testvar'].'<br>';
print_r($_SESSION);
?>
<br>blah1
</body>
</html>
Script 1 output:
Code:
session testvar=test value
Array ( [testvar] => test value )
blah1
and script 2 displays the variable (it should but it doesn't)
Code:
<php?
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>session test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
echo "session testvar=".$_SESSION['testvar'].'<br>';
print_r($_SESSION);
?>
<br>blah2
</body>
</html>
Script2 output - the SESSION value is blank?!:
Code:
session testvar=
blah2
You can see my phpinfo()here (unsafe - I know):
link
I'm really pulling my hair out over this!
Cheers.