Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php session with SQL\Session / reroute() and rollback() #302

Open
kumy opened this issue Aug 18, 2020 · 0 comments
Open

php session with SQL\Session / reroute() and rollback() #302

kumy opened this issue Aug 18, 2020 · 0 comments

Comments

@kumy
Copy link
Contributor

kumy commented Aug 18, 2020

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant