I took me some time to find why my newly added sessions values where not saved in database when using reroute(), so I thought this might need some note in the documentation.
In my context I was adding some flash messages in the SESSION while I was in a transaction. When something wrong happen, I issued reroute() (without explicitly issuing a rollback() - and db server auto-commit off) and then lose the fresh session values.
Basic code would be:
<?php
$db = $f3->get('DB');
new \SQL\Session($db);
$db->begin();
$f3->set('SESSION.flag', true);
// Do something…
// $db->rollback(); // Without this, the session values are also reverted.
$f3->reroute('…');
// On next page, the `SESSION.flag` should be absent :/
It could be easy to forget the rollback() call, this could probably be written somewhere in the documentation? :)
I took me some time to find why my newly added sessions values where not saved in database when using
reroute()
, so I thought this might need some note in the documentation.In my context I was adding some flash messages in the
SESSION
while I was in a transaction. When something wrong happen, I issuedreroute()
(without explicitly issuing arollback()
- and db server auto-commit off) and then lose the fresh session values.Basic code would be:
It could be easy to forget the
rollback()
call, this could probably be written somewhere in the documentation? :)