What Sets Returnurl Value In Yii 1.x Application (Or Framework Internals)

Reposting my own question from Stack Overflow, where it didn’t get enough attention for past few days.

What is responsible for setting returnUrl property in Yii 1.x (documentation says nothing about this) and what value this property should have, if I redirect user back to login screen (user/login route) in actionLogout?

I’m facing a strange situation in my Yii application. As I wrote, my logout action redirects user back to login page. Everything seems fine, when standard user uses only frontend of my application. It logs in and logs out and all the time navigates between home page and login screen, which is fine.

However, when admin-like user logs in, goes to control panel, clicks logout link there and then logs in again, it is redirected to home page. This is, because returnUrl is set to entry script URL, not to admin.html (route to Admin module, which user has just left). I have no idea, why is this happening?

I’ve searched entire code of my application and I can clearly see, that I don’t set returnUrl myself anywhere.

If another Stack Overflow question is the answer, then question is a bit different: Why this is not set by Yii internals, only have to be done by user (in beforeAction)?