Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to get previous url
  • 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.
  • the raw previous URL, if it exists, is stored in $_SERVER['HTTP_REFERER'], see

    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.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion