yii\web\View Does not have a function called redirect thus throwing an error. I assumed you copied it from the controller. The controller base class has an function called redirect that’s why it works there.
You should check the user session variable in the controller before you render the page and just redirect/render the right page from the get go instead of potentially rendering a page just to redirect and using uneeccsary resources.
If you need help post your controller action that renders the page you are putting the redirect on.