I tried to search on google and yii forum about the yii db session, but I couldn’t find any solutions or alternatives.
My question is:
Does the db user session afected by rollback on the same component in a transaction?
E.g.: new model on actionSave, make some value changes in the session and rollback.
And if so, do I need to make a new db compontent? Or make nested transaction on a session level?
Thanks in advance
Hi Gildo, I’m a bit confused about what you are calling a session here, do you mean the transaction?
The logic is: any DB changes inside a transaction will get undone upon rollback, independent if there is one or more Yii2 components/models/etc involved.
I was refering to the “yii\web\DbSession”, configured at “session” component.
As far as I understand, the session data won’t be written to the storage until it is explicitly closed by calling Session::close(), or, more likely, until it is implicitly closed when the application get terminated.
So, I think you can safely call Session::get() and Session::set() inside a db transaction block as long as you avoid closing the session.