At it's simplest, if file_1.php contains
<?php
session_start();
$_SESSION["test_message"] = "Hello, world";
header("Location: http://localhost/file_2.php");
?>
and file_2.php contains
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<?php
if (!(isset($_SESSION["test_message"])))
echo "Test message is not set";
else
echo $_SESSION["test_message"];
var_dump($_SESSION);
session_destroy();
?>
</body>
</html>
the result is Test message is not set
and a var_dump($_SESSION) returns null
- locally, with Xampp
. However, if I upload those same files to a paid-for hosted web site, it works and I see
Hello, world
array
'test_message' => string 'Hello, world' (length=12)
When I look at PHPinfo under Xampp it shows Session Support enabled
. What am I doing wrong?