I am upgrading from PHP 5.6 to PHP 7 and a strange problem occurred.
<?php
session_start();
$_SESSION['test'] = true;
$var = $_SESSION;
session_unset();
print_r($var);
PHP 5.6 Output:
Array
(
[test] => 1
)
PHP 7 Output:
Array
(
)
I assume this is happening because $_SESSION
is passed by reference, but why?
To conclude, it was a bug that is now fixed starting with PHP 7.0.13. Details in comments of the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With