system/classes/Redirect.php
public function saveUrl($url = false, $append = '')
    {
        // If no URL is specified, then save the current URL.
        if ($url == false) {
            $url = '//'.$this->config['base_url'].$_SERVER['REQUEST_URI'];
        }
        
        // Set saved URL
        $this->saved = $this->getRedirect($url).$append;
        
        // Also save URL to session, in-case it won't be used until next request.
        $this->session->savedUrl = $this->saved;
    }
public function saveUrl($url = false, $append = '')
    {
        // If no URL is specified, then save the current URL.
        if ($url == false) {
            $url = '//'.$this->config['base_url'].$_SERVER['REQUEST_URI'];
        }
        
        // Set saved URL
        $this->saved = $this->getRedirect($url).$append;
        
        // Also save URL to session, in-case it won't be used until next request.
        $this->session->savedUrl = $this->saved;
    }
For situations such as where a not-logged-in user tries to access a restricted page,
you may want to save the URL they were trying to go to, so you can try forwarding them
to it again after they login.