echo $_SESSION["favanimal"];
$_SESSION["favanimal"] = "cat";
$cache=Cache::instance();
$sessionCache=new Cache('folder=core/sessions/');
$session=new Session(NULL,NULL,$sessionCache);
var_dump($f3->get('SESSION'));
$f3->set('SESSION.sth', "works");
public function test()
{
if($f3->verb==="POST")
{
$f3->set('SESSION.var', "session vars just work");
}
echo "SESSION VAR : ".$f3->get('SESSION.var');
echo "<form method='post' action=''><input value='press the button' type='submit'></form>"
}
var website="https://domain.com";
$.ajax({
type: 'POST',
url: website+'/api/test1',
cache: false,
data: {}
})
$f3->route('GET|POST /api/test1',
function ($f3){
if($f3->get('POST'))
{
$f3->set('SESSION.var', "session vars just work1");
}
echo "POST? : "; var_dump($f3->get('POST')) ;
echo "SESSION VAR : ".$f3->get('SESSION.var');
echo "<form method='post' action=''><input name='cosss' value='cos' type='text'> <input value='press the button' type='submit'></form>";
});
To set a variable in a Cache-bases Session?
In your example code, it's not clear what is called on GET or POST and also is the cache + session initialisation also happening on get request?
Is the POST request made from ajax or another device?
Is the session cookie sent on POST?
$f3->set('CORS.origin',$domain);
$f3->set('CORS.credentials',true);
$.ajax({ type: 'POST', url: url, cache: false, xhrFields: { withCredentials: true });