I have a php function that's run when a build.php page is loaded and creates a $variable. I have save.php also, which is called via an ajax function in scripts.js (taking data sent through POST), but I need to use $variable in save.php.
Is there a good way to send further data through ajax without it being visible on the front end?
I thought of using a $_SESSION variable for this, which seems like it would work, but I understand it may not be totally reliable and is not always a good idea (though this might have been overstated where I was looking).
Is that the best way? Or is there some other way to get a PHP variable to another one via javascript without it being in the front end code?