I'm still new in yii2 and I'm trying to make my admin user able to switch to another user so he can see the pages exactly like this users (If they report any problem/bug).
I found the switchIdentity()
method, but I just can't figure out how to call this $identity
.
By the way, you guys think this is the best way for an admin check the "user view" or anyone have a better idea?
OK, i found a solution. We just need the id of the user we want to login as. I called
$id
.Now that we changed the user, we just need to check if the session have stored the admin Id. If does, some action can be called to go back to our original user. Like this:
I hope this can help someone and sorry i don't know how to edit the codes properly in the comments.