I have 2 php files, in the first file:
<?php
session_start();
.
.
.
$_SESSION['favcolor'] = "green";
echo "ses: ".$_SESSION['favcolor'];
?>
and in the second file:
<?php
session_start();
echo "ses: ".$_SESSION['favcolor'];
?>
When executing the first page, i do see the correct favcolor but when executing the second page in the same browser, I get {"error":"Undefined index: favcolor"}. I know I need to check the existence of this key before using it but I was wondering why it's not there in the first place because this is what I want to achieve, the store/restore a session value between PHP calls. What am I missing?