Page 1 of 1

environment variable to redirect user to referrer page

Posted: Wed Nov 25, 2009 1:01 pm
by abushahin
hi, i just wondered if i collect the http referrer using

Code: Select all

$_SERVER['HTTP_REFERER'];
inside a variable or hidden field how can i use this to send the user to that page after some sort of validation, i.e login.
ps, the user may have been browsing the page without logging in but when he presses a link to add comment he needs to login so how do i send the user to that page after login if that makes sense, many thanks abu

Re: environment variable to redirect user to referrer page

Posted: Wed Nov 25, 2009 2:55 pm
by superdezign
Don't bother using referrer. A user can set their browser to hide that information. What you want to do is send a GET variable to your login page. So, when an unregistered user tries to load a page:

Code: Select all

if (!$user->isValid()) {
  header("Location: http://domain.tld/login?lastPage=somePage");
}