Return to previous URL after logging in

Hello, when a user clicks a button to login, it takes them to the login page. After they login, I would like to redirect them back to the page before they clicked the login page. I am currently using $this->goBack() however it always redirects them to the home page no matter what.

Is this because the login page is a separate page, and it redirecting them to the login page, which redirects them to the home page? If this is the case, how can I fix it?

This quote is from Yii2 doc:

Here

+1[sup]323[/sup]