src/Web/User.php
public function getReturnUrl($defaultUrl = null)
    {
        $url = $this->app->session->get($this->returnUrlParam, $defaultUrl);
        if (is_array($url)) {
            if (isset($url[0])) {
                return $this->app->urlManager->createUrl($url);
            }

            $url = null;
        }

        return $url === null ? $this->app->urlManager->getHomeUrl() : $url;
    }
public function getReturnUrl($defaultUrl = null)
    {
        $url = $this->app->session->get($this->returnUrlParam, $defaultUrl);
        if (is_array($url)) {
            if (isset($url[0])) {
                return $this->app->urlManager->createUrl($url);
            }

            $url = null;
        }

        return $url === null ? $this->app->urlManager->getHomeUrl() : $url;
    }
Returns the URL that the browser should be redirected to after successful login.

This method reads the return URL from the session. It is usually used by the login action which
may call this method to redirect the browser to where it goes after successful authentication.

@param string|array $defaultUrl the default return URL in case it was not set previously.
If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to.
Please refer to [[setReturnUrl()]] on accepted format of the URL.
@return string the URL that the user should be redirected to after login.
@see loginRequired()