Okay I got a series of pages in order to understand session variables in php. The pages I am using are listed below:
Page1.php source: (form):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Get name value for the session variable</title>
</head>
<body>
<form method="post" action="page2.php">
Enter your Name: <input type="text" name="name">
<input type="submit" value="Submit">
</form>
</body>
</html>
Page2.php source:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "<b>Step 2 - Register Session </b><br />";
// Get the user's input from the form
$name = $_POST['name'];
// Register session key with the value
$_SESSION['name'] = $name;
// Display the session information:
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Register session and display</title>
</head>
<body>
Welcome to my website <b><? echo $_SESSION['name']; ?></b>!<br />
Let's see what happens on the <a href="page3.php">next page.</a><br /><br />
</body>
</html>
Page3.php source:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Retrieve and display session variable</title>
</head>
<body>
<b>Step 3 - Test Session Part II </b><br />
Hey <b><? echo $_SESSION['name']; ?></b> Everything is still working!<br /><br />
</body>
</html>
-----------------------------------------------------------------
register_globals is set to OFF, I am using:
php v4.3.4
Apache 2.0.48
WinXP Prof
phpinfo() for my local machine can be viewed here
Basically the first two pages work 100% but on the third page it doesn't display the session var for some reason...? This is causing a GREAT deal of frustration. :mad:
It works 100% on our ISP as they have register_globals = ON but as I've read, this is not good coding practise...
Any response would be appreciated!
Regards,
Brett