I have a function with a reference parameter. The function populates the reference with an array. When it returns I test the reference value with a print_r()
. It's successful. But when I try and assign it to another var as in,
$_SESSION['allvats'] = $ref_all_vats;
I get an empty session var. How do I assign this? I've tried declaring the reference as an array before invoking the function and also assigning to sessions as
$_SESSION['allvats'][] = $ref_all_vats;
Thank you.
Edit.
Session is running. Other SESSION vars populate. Here is the code bit:
if(buildMetalArrayNsp($process_id, $ref_all_vats)) {
writeDataToFile("vats " . print_r($ref_all_vats, true), __FILE__, __LINE__);
$_SESSION['allvats'] = $ref_all_vats;
}
Here is the session code:
$lifetime= 60 * 60 * 24 * 30; // 30 days
session_start();
setcookie(session_name(),session_id(),time()+$lifetime);