We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How can I transfer some user data from Middleware to Controller?

Hello.

Can I transfer some user data from Middleware to Controller?

For example, I get user's ID in my Middleware and I whant to take this ID to my Controller.. and do smth with it there.

How to do it right? Or should I get the data twice?

just use some ACL middleware example. but actually it depends on application layout - is it real "middleware" or just a hook on beforeExecuteRoute

With services in controller just call $this->getDi()->get('middlewarePlugin')->getSomethingCached()