For some reasons I don't know, Response::redirect_back is not working on my login page. How can I get the user's previous url myself so that I can manually redirect them back to where they came from? If there's a way to make Response::redirect_back work I'd prefer that.
As this is not secure, and can be faked / overridden by clients, Response::redirect_back() will only redirect back if the previous URL is pointing to a page within the current application. If will not redirect to an external page.
Is there a way to make Response::redirect_back() work? I don't even know what the problem is 'cos I use it on other pages and it works but it doesn't on my login page.
It works, I'm sure of that. But you have to find out why it doesn't function in your specific case.
To make it work, you need to have the correct $_SERVER['HTTP_REFERER']. So start by debugging that, what does it contain at the place you want to do a redirect back? And is that where you want to redirect to?
This variable is only updated by the server on page requests, so anything you do locally (like ajax updates, fetching screen elements using ajax, etc), do not update this.
Also, once you've used Response::redirect(), you can no longer use redirect_back(), as a redirect updates the referrer URL.