I'm having a really strange problem with some of my PHP code. I have error reporting turned on and nothing's coming up either.
Basically I have a form that pushed data to $_SESSION[]. The code is:
<?php
session_start();
$_SESSION['contact']['name'] = $_GET['name'];
$_SESSION['contact']['email'] = $_GET['email'];
$_SESSION['contact']['question'] = $_GET['question'];
session_write_close();
header('Location: confirm.php');
exit;
?>
This is working. However, completely at random the confirm.php will or will not recieve this data. If I refresh multiple times I sometimes get the data, sometimes not.
Here's the confirm code:
<?php
ini_set('display_errors', 'on');
error_reporting(-1);
session_start();
print "SeshID:" . session_id() . "<br>";
print "CookieID:" . $_COOKIE['PHPSESSID'] . "<br>";
print "Status" . session_status() . "<br>";
print "Loc" . session_save_path() . "<br>";
print "Cookie";
print_r(session_get_cookie_params());
print "<br>Data:<br>";
print_r($_SESSION);
?>
Again, no errors. Nothing appearing that looks obviously wrong.
The strange thing is that sometimes when I refresh the confirm page I will get an empty "Array ( )". Sometimes I'll get "Array ( [contact] => Array ( [question] => test [name] => [email] => test@test.com) )" for seemingly no reason...
I'm running no other scripts in between doing this - only the script above that checks the content of the session (confirm) need be re-ran and only the data somehow changes. I run the form a few times, then this check script and it's entirely inconsistent. The session and cookie IDs never change and are always the same
Is there some PHP setting I'm missing? It's really weird to me that these are seemingly pulling out old data which has been overwritten.