Welcome Guest, Not a member yet? Register   Sign In
How get referring URL?
#3

[eluser]thurting[/eluser]
$_SERVER['HTTP_REFERER'] is inconsistent so it isn't the best solution.

The best method is to store the referring URL into a session variable. Something like below would work but obviously needs to be changed to fit you specs - it is just to help you get started.

Code:
function _authorize()
{
  // maybe use $this->uri->uri_string() or $this->uri->ruri_string(n) below
  $_SESSION['referer'] = $_SERVER['PHP_SELF'];

  if (!AUTHORIZED)
  {
    REDIRECT TO LOGIN
  }
}

function index ()
{
  $this->_authorize();
}

function login ()
{
  $user = $this->user_model->authenticate();

  if ($user)
  {
    AUTHORIZE
    $url = (isset($_SESSION['referer']))? $_SESSION['referer'] : 'index';
    unset($_SESSION['referer']);
    redirect($url);
  }
}

you could probably use CI sessions but I prefer to use native sessions for something like this.


Messages In This Thread
How get referring URL? - by El Forum - 08-25-2007, 12:44 PM
How get referring URL? - by El Forum - 08-25-2007, 08:03 PM
How get referring URL? - by El Forum - 08-25-2007, 10:30 PM
How get referring URL? - by El Forum - 08-26-2007, 11:10 AM
How get referring URL? - by El Forum - 08-26-2007, 02:12 PM
How get referring URL? - by El Forum - 08-06-2008, 10:06 AM
How get referring URL? - by El Forum - 08-06-2008, 10:17 AM
How get referring URL? - by El Forum - 08-06-2008, 11:03 AM
How get referring URL? - by El Forum - 08-06-2008, 11:03 AM
How get referring URL? - by El Forum - 09-17-2010, 10:10 AM
How get referring URL? - by El Forum - 06-02-2012, 10:27 AM
How get referring URL? - by El Forum - 06-02-2012, 01:44 PM
How get referring URL? - by El Forum - 06-02-2012, 02:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB