Surprisingly i have quite a site built so far and am loving the framework, however i just learned that unless hive values are set at the router page, they can't be set or recalled from other pages.
Things i've tested
- I have the SQL (MYSQL) session tracking enabled, seems to work.
On the top of each page i call my main classes file and my dbconnection.php file that has the
$sess=new DB\SQL\Session($db);
$f3->CSRF=$sess->csrf();
in it
So for example
i have
index.php (router)
files.php (the page that is rendered when you go to /files
controller-files.php (the page that handles ajax queries from files.php)
I have a ton of action going on and that all works. But i've come up with a neat function that needs to store a variable in the hive and then when called differently, retrieve the hive value.
For example.
files.php has ajax that sends a request to
/controller/files/downloadfile (/controller/@controllername/@action)
There is a function within controller-files.php that gets passed the @action parameter.
if ($f3->get('action') == 'downloadfile') //download file chosen
{
$fid='22';
$f3->set('FID',$fid);
echo "/controller/files/fetchfile?token=1vs657xz46eax.1mqc8nthaz5c4";
}
essentially it returns a path i pass to hidden iframe that is supposed to request a file for download. However, on firing the iframe it goes to the controller-files.php again and checks this code and fails.
if ($f3->get('action') == 'fetchfile')
{
echo $f3->get('FID'); //results in nothing
if ($f3->exists('FID')) {
//do something
}
else
{
echo "FID doesn't exist";
}
}
This always returns "FID doesn't exist". meaning that the $f3->set('FID',$fid); no longer exists!
It would seem unless something is assigned in the router (index.php) and passed to the called pages the hive is destroyed!
Could someone explain what needs to happen on each PHP to keep the hive and session alive?I can see my session in the MYSQL table but even writing to the session doesn't stick from child pages. i.e. $f3->set('SESSION.TEST','working'); cant get called from another rendered page using $f3->get('SESSION.TEST'); or $f3->exists('SESSION');
help!